免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
常用加解密工具類(MD5、SHA、DES、AES、RSA)


  解密工具類,實(shí)現(xiàn)了常用的加解密類。包括單向加密:MD5、SHA;對(duì)稱加密:DES、AES;非對(duì)稱加密:RSA

  完整代碼見(jiàn):https://git.oschina.net/bayern.com/SecureUtils.git  同時(shí)提供ant打包腳本。

  下面展示部分關(guān)鍵代碼

MD5 單向加密:    /**     * 返回MD5單向加密后的十六進(jìn)制字符串     * @param data     * @return     * @throws Exception     */    public String getEncryptForHex(byte[] data) throws Exception    {        byte[] digestData = encrypt(data);        StringBuffer hex = new StringBuffer();        for(int i = 0; i < digestdata.length;="" i++)=""  =""  =""  =""  {=""  =""  =""  =""  =""  =""  int="" h="((int)digestData[i])" &="" 0xff;=""  =""  =""  =""  =""  =""  if(h="">< 16)=""  =""  =""  =""  =""  =""  {=""  =""  =""  =""  =""  =""  =""  =""  hex.append('0');=""  =""  =""  =""  =""  =""  }=""  =""  =""  =""  =""  =""  hex.append(integer.tohexstring(h));=""  =""  =""  =""  }=""  =""  =""  =""  return="" hex.tostring();=""  =""  }="" des="" 對(duì)稱加密類:=""  =""  @override=""  =""  public="" byte[]="" encrypt(byte[]="" data)="" throws="" exception=""  =""  {=""  =""  =""  =""  if(secretkey="=" null="" ||="" ''.equals(secretkey))=""  =""  =""  =""  {=""  =""  =""  =""  =""  =""  throw="" new="" exception('scretkey="" need="" to="" exists');=""  =""  =""  =""  }=""  =""  =""  =""  =""  =""  =""  =""  secretkey="" md5key="getKey(secretKey);"  =""  =""  =""  cipher="" cipher="Cipher.getInstance(ALGORITHM);"  =""  =""  =""  cipher.init(cipher.encrypt_mode,="" md5key);=""  =""  =""  =""  return="" cipher.dofinal(data);=""  =""  }=""  =""  @override=""  =""  public="" byte[]="" decrypt(byte[]="" data)="" throws="" exception=""  =""  {=""  =""  =""  =""  if(secretkey="=" null="" ||="" ''.equals(secretkey))=""  =""  =""  =""  {=""  =""  =""  =""  =""  =""  throw="" new="" exception('scretkey="" need="" to="" exists');=""  =""  =""  =""  }=""  =""  =""  =""  =""  =""  =""  =""  secretkey="" md5key="getKey(secretKey);"  =""  =""  =""  cipher="" cipher="Cipher.getInstance(ALGORITHM);"  =""  =""  =""  cipher.init(cipher.decrypt_mode,="" md5key);=""  =""  =""  =""  return="" cipher.dofinal(data);=""  =""  }="" rsa="" 非對(duì)稱加密。私鑰加密="" &="" 私鑰解密="" &="" 私鑰簽名=""  =""  @override=""  =""  public="" byte[]="" encrypt(byte[]="" data)="" throws="" exception=""  =""  {=""  =""  =""  =""  privatekey="" rsaprivatekey="getRSAPrivateKey();"  =""  =""  =""  cipher="" cipher="Cipher.getInstance(ALGORITHM);"  =""  =""  =""  cipher.init(cipher.encrypt_mode,="" rsaprivatekey);=""  =""  =""  =""  return="" cipher.dofinal(data);=""  =""  }=""  =""  @override=""  =""  public="" byte[]="" decrypt(byte[]="" data)="" throws="" exception=""  =""  {=""  =""  =""  =""  privatekey="" rsaprivatekey="getRSAPrivateKey();"  =""  =""  =""  cipher="" cipher="Cipher.getInstance(ALGORITHM);"  =""  =""  =""  cipher.init(cipher.decrypt_mode,="" rsaprivatekey);=""  =""  =""  =""  return="" cipher.update(data);=""  =""  }=""  =""  =""  =""  /**=""  =""  ="" *="" 使用私鑰="" 對(duì)數(shù)據(jù)進(jìn)行簽名=""  =""  ="" *="" @param="" data=""  =""  ="" *="" @return=""  =""  ="" *="" @throws="" exception=""  =""  ="" */=""  =""  public="" string="" sign(byte[]="" data)="" throws="" exception=""  =""  {=""  =""  =""  =""  privatekey="" rsaprivatekey="getRSAPrivateKey();"  =""  =""  =""  signature="" signature="Signature.getInstance(SIGN_ALGORITHM);"  =""  =""  =""  signature.initsign(rsaprivatekey);=""  =""  =""  =""  signature.update(data);=""  =""  =""  =""  return="" encoder(signature.sign());=""  =""  }="" rsa="" 非對(duì)稱加密。公鑰加密="" &="" 公鑰解密="" &="" 公鑰校驗(yàn)簽名=""  =""  @override=""  =""  public="" byte[]="" encrypt(byte[]="" data)="" throws="" exception=""  =""  {=""  =""  =""  =""  if(publickey="=" null="" ||="" ''.equals(publickey))=""  =""  =""  =""  {=""  =""  =""  =""  =""  =""  throw="" new="" exception('publickey="" is="" need="" exists');=""  =""  =""  =""  }=""  =""  =""  =""  =""  =""  =""  =""  publickey="" rsapublickey="getRSAPublicKey(publicKey);"  =""  =""  =""  cipher="" cipher="Cipher.getInstance(ALGORITHM);"  =""  =""  =""  cipher.init(cipher.encrypt_mode,="" rsapublickey);=""  =""  =""  =""  return="" cipher.dofinal(data);=""  =""  }=""  =""  @override=""  =""  public="" byte[]="" decrypt(byte[]="" data)="" throws="" exception=""  =""  {=""  =""  =""  =""  if(publickey="=" null="" ||="" ''.equals(publickey))=""  =""  =""  =""  {=""  =""  =""  =""  =""  =""  throw="" new="" exception('publickey="" is="" need="" exists');=""  =""  =""  =""  }=""  =""  =""  =""  =""  =""  =""  =""  publickey="" rsapublickey="getRSAPublicKey(publicKey);"  =""  =""  =""  cipher="" cipher="Cipher.getInstance(ALGORITHM);"  =""  =""  =""  cipher.init(cipher.decrypt_mode,="" rsapublickey);=""  =""  =""  =""  return="" cipher.dofinal(data);=""  =""  }=""  =""  /**=""  =""  ="" *="" 使用公鑰校驗(yàn)簽名=""  =""  ="" *="" @param="" data=""  =""  ="" *="" @param="" sign=""  =""  ="" *="" @return=""  =""  ="" *="" @throws="" exception=""  =""  ="" */=""  =""  public="" boolean="" verifysign(byte[]="" data,="" string="" sign)="" throws="" exception=""  =""  {=""  =""  =""  =""  if(publickey="=" null="" ||="" ''.equals(publickey))=""  =""  =""  =""  {=""  =""  =""  =""  =""  =""  throw="" new="" exception('publickey="" is="" need="" exists');=""  =""  =""  =""  }=""  =""  =""  =""  =""  =""  =""  =""  publickey="" rsapublickey="getRSAPublicKey(publicKey);"  =""  =""  =""  signature="" signature="Signature.getInstance(SIGN_ALGORITHM);"  =""  =""  =""  signature.initverify(rsapublickey);=""  =""  =""  =""  signature.update(data);=""  =""  =""  =""  return="" signature.verify(decoder(sign));=""  ="">

  via:phpxs.com


本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
加密算法介紹及如何選擇加密算法 , 密鑰,算法,加密算法,加密,密碼學(xué),密碼,對(duì)稱,ecc...
酷貼!3DES、AES、RC6、TEA、RSA、MD5、SHA1、SHA256加密源碼大聚...
加密算法介紹及如何選擇加密算法
DES、AES、RSA等常用加密算法介紹與比較
(原創(chuàng))System.Security.Cryptography中定義的加密算法
為了系統(tǒng)安全,嵌入式工程師得知道這幾種實(shí)用加密算法!
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服