Last active
May 19, 2017 16:14
-
-
Save alexaleluia12/0dde0861fda8a470708e00510ecea4a6 to your computer and use it in GitHub Desktop.
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
<?php | |
// mandar dados do usuario na url para confirmacao de email | |
// gerar arquivo ini com key mais iv | |
// ******************************** | |
$fileObj = fopen('senha.ini', 'w'); | |
$sh = openssl_random_pseudo_bytes(32); | |
$iv = openssl_random_pseudo_bytes(16); | |
fwrite($fileObj, "senha = " . bin2hex($sh) . PHP_EOL); | |
fwrite($fileObj, "iv = " . bin2hex($iv) . PHP_EOL); | |
fclose($fileObj); | |
// ******************************** | |
// embaralhar e voltar dado | |
$r = parse_ini_file('senha.ini'); | |
// echo hex2bin($r['senha']); | |
$sh = hex2bin($r['senha']); | |
$iv = hex2bin($r['iv']); | |
$alvo = 6; | |
$embaralhado = openssl_encrypt($alvo, 'AES-128-CBC', $sh, OPENSSL_RAW_DATA, $iv); | |
$ak = bin2hex($embaralhado); | |
echo $ak; | |
echo "<br>"; | |
$volta = openssl_decrypt(hex2bin($ak), 'AES-128-CBC', $sh, OPENSSL_RAW_DATA, $iv); | |
echo $volta; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment