Googleinurl

[Class] Criptografia SHA256 PHP

Dec 10th, 2014
746
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class Criptografia {
  4.  
  5.     private $chave = null, $iv = null;
  6.  
  7.     function __construct($senha) {
  8.         $this->chave = hash('SHA256', $senha, TRUE);
  9.         $this->iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_DEV_RANDOM);
  10.     }
  11.  
  12.     function encrypt($input) {
  13.         return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->chave, $input, MCRYPT_MODE_ECB, $this->iv));
  14.     }
  15.  
  16.     function decrypt($input) {
  17.         return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->chave, base64_decode($input), MCRYPT_MODE_ECB, $this->iv));
  18.     }
  19.  
  20. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×