Skip to content

Instantly share code, notes, and snippets.

@clevertechru
Last active December 26, 2015 20:59
Show Gist options
  • Save clevertechru/7212808 to your computer and use it in GitHub Desktop.
Save clevertechru/7212808 to your computer and use it in GitHub Desktop.
Вот такое простенькое обратимое шифрование можно использовать. Перед шифрованием хорошо в base64 завернуть, что бы уж точно не поломалось ничего.
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