Data encryption translates data into another form, or code so that only people with access to a secret key (formally called a decryption key) or password can read it. Encrypted data is commonly referred to as ciphertext, while unencrypted data is called plaintext. Currently, encryption is one of the most popular and effective data security methods used by organizations. Two main types of data encryption exist - asymmetric encryption, also known as public-key encryption, and symmetric encryption.
<?php //sting which you want to encrypt $str = 'http://www.phpjavascript.com/'; //the secryt key which encrypts the sting $ky = 'ZCVGEGLLLS'; if ($ky == '') { echo $str; } else { $ky = str_replace(chr(32), '', $ky); if (strlen($ky) < 8) { echo 'the key length should be more than 8'; } else { $kl = strlen($ky) < 32 ? strlen($ky) : 32; $k = array(); for ($i = 0; $i < $kl; $i++) { $k[$i] = ord($ky{$i}) & 0x1F; } $j = 0; for ($i = 0; $i < strlen($str); $i++) { $e = ord($str{$i}); $str{$i} = $e & 0xE0 ? chr($e ^ $k[$j]) : chr($e); $j++; $j = $j == $kl ? 0 : $j; } echo $str; } } ?>
Result:
rwbw?(#{{d4s~wofzmphjfs+dca#
No comments:
Post a Comment