<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
$user = 'chameleon';
echo 'user → '.$user.'<br /><br /><br />';
// 加密
for($x=0;$x<strlen($user);$x++)
{
$user = substr_replace ($user, chr(~ord(substr($user,$x,1))), $x, 1);
}
echo '加密後字串 → '.$user;
echo '<br /><br /><br />';
// 解密
for($x=0;$x<strlen($user);$x++)
{
$user = substr_replace ($user, chr(~ord(substr($user,$x,1))), $x, 1);
}
echo '解密後 → '.$user;
?>
</body>
</html>
執行結果
相關筆記 ----
【Delphi】簡易 加/解 密字串
沒有留言:
張貼留言