欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php實(shí)現(xiàn)基于openssl的加密解密方法

 更新時(shí)間:2016年09月30日 11:09:31   作者:小松博客  
這篇文章主要介紹了php實(shí)現(xiàn)基于openssl的加密解密方法,結(jié)合實(shí)例形式分析了php自定義函數(shù)實(shí)現(xiàn)基于openssl的加密解密操作相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了php實(shí)現(xiàn)基于openssl的加密解密方法。分享給大家供大家參考,具體如下:

通過openssl加密解密方法

1. openssl加密方法:

function encrypt($id){
  $id=serialize($id);
  $key="1112121212121212121212";
  $data['iv']=base64_encode(substr('fdakinel;injajdji',0,16));
  $data['value']=openssl_encrypt($id, 'AES-256-CBC',$key,0,base64_decode($data['iv']));
  $encrypt=base64_encode(json_encode($data));
  return $encrypt;
}

2. openssl解密方法:

function decrypt($encrypt)
{
  $key = '1112121212121212121212';//解密鑰匙
  $encrypt = json_decode(base64_decode($encrypt), true);
  $iv = base64_decode($encrypt['iv']);
  $decrypt = openssl_decrypt($encrypt['value'], 'AES-256-CBC', $key, 0, $iv);
  $id = unserialize($decrypt);
  if($id){
    return $id;
  }else{
    return 0;
  }
}

PS:關(guān)于加密解密感興趣的朋友還可以參考本站在線工具:

密碼安全性在線檢測:
http://tools.jb51.net/password/my_password_safe

高強(qiáng)度密碼生成器:
http://tools.jb51.net/password/CreateStrongPassword

MD5在線加密工具:
http://tools.jb51.net/password/CreateMD5Password

迅雷、快車、旋風(fēng)URL加密/解密工具:
http://tools.jb51.net/password/urlrethunder

在線散列/哈希算法加密工具:
http://tools.jb51.net/password/hash_encrypt

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php加密方法總結(jié)》、《PHP編碼與轉(zhuǎn)碼操作技巧匯總》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計(jì)算法總結(jié)》、《php正則表達(dá)式用法總結(jié)》、及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論