91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6KB
    文件類(lèi)型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-15
  • 語(yǔ)言: Java
  • 標(biāo)簽:

資源簡(jiǎn)介

簡(jiǎn)單的數(shù)字簽名系統(tǒng)、java、可運(yùn)行、簡(jiǎn)單的數(shù)字簽名系統(tǒng)

資源截圖

代碼片段和文件信息

package?jct;


import?javax.crypto.*;
import?javax.crypto.spec.*;
import?java.security.Key;
import?java.security.KeyFactory;
import?java.security.spec.EncodedKeySpec;
import?java.security.Security;
import?java.security.*;
import?java.util.Random;
import?java.util.Vector;

/**
?*?

封裝同Blowfish對(duì)稱(chēng)加密算法有關(guān)的方法,包括了使用創(chuàng)建Blowfish密碼,使用Blowfish加密、解密?使用PBE(基于口令的加密)存取blowfiwsh密碼?


?*?@Copyright:WDSsoft
?*?@ad:WDSsoft?“企業(yè)多級(jí)數(shù)字簽名系統(tǒng)”-?最佳的企業(yè)電子文檔多級(jí)數(shù)字簽名方案
?*?@URL:www.wdssoft.com
?*?@作者?吳東升?mdss@wdssoft.com?bluesunday@sohu.com
?*/



public?class?BlowfishTool?{

??public?BlowfishTool()?{
??}
/**
?*?使用Blowfish加密
?*?@param?Key?key:密碼
?*?@param?byte[]?text:明文
?*?@return?byte[]:密文
?*/
??public?static?byte[]?encryptReturnByte(Key?keybyte[]?text){
?????try{
?????????Cipher?cipher=Cipher.getInstance(“Blowfish/ECB/PKCS5Padding“);
?????????cipher.init(Cipher.ENCRYPT_MODEkey);
?????????return?cipher.doFinal(text);
?????}catch(Exception?e){??return?null;????}
??}
/**
?*?Blowfish解密
?*?@param?Key?key:密碼
?*?@param?byte[]?text:密文
?*?@return?byte[]?:?明文
?*/
???public?static?byte[]?decryptReturnByte(Key?keybyte[]?text){
?????try{
?????????Cipher?cipher=Cipher.getInstance(“Blowfish/ECB/PKCS5Padding“);
?????????cipher.init(Cipher.DECRYPT_MODEkey);
?????????return?cipher.doFinal(text);
?????}catch(Exception?e){??return?null;}
???}
/**
?*?使用PBE保管Blowfish密碼
?*?@param?Key?targetKey:?Blowfish密碼
?*?@param?char[]?password:?口令
?*?@return?Vector-element1:byte[]:密文-element2:byte[]:鹽
?*/

????public?static?Vector?wrapKey(Key?targetKeychar[]?password){
???????try{
??????????PBEKeySpec?keySpec=new?PBEKeySpec(password);
??????????SecretKeyFactory?keyFactory=SecretKeyFactory.getInstance(“PBEWithMD5AndDES“);
??????????SecretKey?key=keyFactory.generateSecret(keySpec);
??????????Cipher?cipher=Cipher.getInstance(“PBEWithMD5AndDES“);
??????????byte[]?salt=new?byte[8];
??????????Random?random=new?Random();
??????????random.nextBytes(salt);
??????????PBEParameterSpec?paramSpec=new?PBEParameterSpec(salt100);
??????????cipher.init(cipher.WRAP_MODEkeyparamSpec);
??????????Vector?encryptedKey=new?Vector();
??????????encryptedKey.addElement(cipher.wrap(targetKey));
??????????encryptedKey.addElement(salt);
??????????return?encryptedKey;
???????}catch(Exception?e){e.printStackTrace();
??????????return?null;
????????}
????}
/**
?*?取出PBE加密的密鑰
?*?@param?Vector?encryptedKey-element1:byte[]:密文-element2:byte[]:鹽
?*?@param?char[]?password:口令
?*?@return?Key:Blowfish密碼
?*/
??public?static?Key?unwrapKey(Vector?encryptedKeychar[]?password){
??????try{

??????????byte[]?wrapedKey=(byte[])encryptedKey.elementAt(0);
??????????byte[]?salt=(byte[])encryptedKey.elementAt(1);
??????????PBEKeySpec?keySpec=new?PBEKeySpec(password);
??????????SecretKeyFactory?keyFactory=SecretKeyFactory.getInstance(“PBEWithMD5AndDES“);
??????????SecretKey?key=keyFactory.generateSecret(keySpec);
??????????Cipher?cipher=Cipher.getInstance(“PBEWithMD5AndDES“);
??????????PBEParameterSpec?paramSpec=new?PBEParameterSpec(salt100);
??????????ciph

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2006-01-04?17:55??jct\
?????文件????????5047??2006-01-04?20:59??jct\RSATool.java
?????文件????????2015??2006-01-04?20:59??jct\Digest.java
?????文件????????4078??2006-01-04?20:59??jct\BlowfishTool.java
?????文件????????4672??2006-01-04?20:59??jct\PBETool.java
?????文件?????????616??2006-01-04?21:28??jct\_Readme.java

評(píng)論

共有 條評(píng)論

相關(guān)資源