Last active
December 26, 2015 20:59
-
-
Save clevertechru/7212808 to your computer and use it in GitHub Desktop.
Вот такое простенькое обратимое шифрование можно использовать. Перед шифрованием хорошо в base64 завернуть, что бы уж точно не поломалось ничего.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function crypt($string, $password = 'secret') { | |
$strLen = strlen($string); | |
$seq = $password; | |
$gamma = ''; | |
while (strlen($gamma) < $strLen) { | |
$seq = sha1($seq.self::SALT, true); | |
$gamma.=substr($seq, 0, 8); | |
} | |
return $string^$gamma; | |
} | |
function encode( $string, $password = 'secret' ) { | |
return base64_encode( crypt( $string, $password ) ); | |
} | |
function decode( $string ,$password = 'secret' ) { | |
return crypt( base64_decode( $string ), $password ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment