Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Criptografia {
- private $chave = null, $iv = null;
- function __construct($senha) {
- $this->chave = hash('SHA256', $senha, TRUE);
- $this->iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_DEV_RANDOM);
- }
- function encrypt($input) {
- return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->chave, $input, MCRYPT_MODE_ECB, $this->iv));
- }
- function decrypt($input) {
- return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->chave, base64_decode($input), MCRYPT_MODE_ECB, $this->iv));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement