admin
管理员
管理员
  • UID1
  • 粉丝0
  • 关注0
  • 发帖数220
阅读:599回复:0

带vi的加解密

楼主#
更多 发布于:2021-05-20 19:18
 //加密
  public function makesign($content,$secretKey){  
 //$secretKey = "your secret key";
 $iv = substr($secretKey, 0, 16);
 //$content = "the original text that needs to be encrypted";
 $encrypted = substr(sha1(microtime()), 0, 9).
    bin2hex(openssl_encrypt($content, 'aes-256-cbc', $secretKey, OPENSSL_RAW_DATA, $iv)).
    substr(sha1(microtime()), 0, 9);
  return $encrypted;
  }
  
 //解密
  public function design($content,$secretKey){  
 $iv = substr($secretKey, 0, 16);
 //$content = "this is the ciphertext content";
 $decrypted = openssl_decrypt(hex2bin(substr($content,9,-9)), 'aes-256-cbc', $secretKey, OPENSSL_RAW_DATA, $iv);
  return $decrypted;
  }
游客

返回顶部