Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Функция шифрования
- function simple_encrypt($text, $salt = "earlysandwich.com")
- {
- return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
- }
- //Функция дешифрования
- function simple_decrypt($text, $salt = "earlysandwich.com")
- {
- return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
- }
- // Шифруемая строка
- $str = 'ddd777uuu888ooo';
- // Encrypt a tring and echo it
- $encoded = simple_encrypt($str, "securedsecuredsecuredfff");
- echo "<br />";
- echo "Зашифровано: ". $encoded;
- echo "<br />";
- // Now to decode the encoded text
- $decoded = simple_decrypt($encoded , "securedsecuredsecuredfff");
- echo "Было: ". $decoded;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement