Home  >  Article  >  php教程  >  php 加密加密字符串函数

php 加密加密字符串函数

PHP中文网
PHP中文网Original
2016-05-26 08:19:021080browse

php代码

function encryptDecrypt($key, $string, $decrypt){
  if($decrypt){
      $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "12");
      return $decrypted;
  }else{
      $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
      return $encrypted;
  }
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn