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

  • 大小: 1.26MB
    文件類(lèi)型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-08-28
  • 語(yǔ)言: 其他
  • 標(biāo)簽: RSA??DEA??安全通信??

資源簡(jiǎn)介

發(fā)送方:
1.獲取發(fā)送的原文
2.利用系統(tǒng)的隨機(jī)數(shù)產(chǎn)生對(duì)稱(chēng)密鑰
3.計(jì)算原文的摘要
4.用自己的私鑰對(duì)摘要進(jìn)行加密(簽名)
5.用對(duì)稱(chēng)密鑰對(duì)(原文和簽名)進(jìn)行加密
6.用對(duì)方的公鑰對(duì)稱(chēng)密鑰進(jìn)行加密(加密密鑰)
7.將密文(5)和加密密鑰(6)一起發(fā)給對(duì)方

接收方:
1.用自己的私鑰對(duì)加密密鑰進(jìn)行解密,得到對(duì)稱(chēng)密鑰--也只有自己才能解密。
2.用對(duì)稱(chēng)密鑰對(duì)密文進(jìn)行解密,得到原文和簽名。
3.計(jì)算原文的摘要
4.用對(duì)方的公鑰對(duì)簽名進(jìn)行解密獲取發(fā)送來(lái)的摘要--身份驗(yàn)證
5.將兩個(gè)摘要進(jìn)行對(duì)比--驗(yàn)證原文的完整性。

資源截圖

代碼片段和文件信息

package?com.cn.sec.rsa;

import?java.io.UnsupportedEncodingException;
import?java.security.Key;
import?java.security.NoSuchAlgorithmException;
import?java.security.SecureRandom;

import?javax.crypto.Cipher;
import?javax.crypto.KeyGenerator;
import?javax.crypto.spec.SecretKeySpec;


public?class?AES?{
/**
?*?加密
?*?
?*?@param?content
?*????????????需要加密的內(nèi)容
?*?@param?password
?*????????????加密密碼
?*?@return
?*/
public?static?byte[]?encrypt(byte[]?data?byte[]?key)?{
CheckUtils.notEmpty(data?“data“);
CheckUtils.notEmpty(key?“key“);
if(key.length!=16){
throw?new?RuntimeException(“Invalid?AES?key?length?(must?be?16?bytes)“);
}
try?{
SecretKeySpec?secretKey?=?new?SecretKeySpec(key?“AES“);?
byte[]?enCodeFormat?=?secretKey.getEncoded();
SecretKeySpec?seckey?=?new?SecretKeySpec(enCodeFormat“AES“);
Cipher?cipher?=?Cipher.getInstance(ConfigureEncryptAndDecrypt.AES_ALGORITHM);//?創(chuàng)建密碼器
cipher.init(Cipher.ENCRYPT_MODE?seckey);//?初始化
byte[]?result?=?cipher.doFinal(data);
return?result;?//?加密
}?catch?(Exception?e){
throw?new?RuntimeException(“encrypt?fail!“?e);
}
}

/**
?*?解密
?*?
?*?@param?content
?*????????????待解密內(nèi)容
?*?@param?password
?*????????????解密密鑰
?*?@return
?*/
public?static?byte[]?decrypt(byte[]?data?byte[]?key)?{
CheckUtils.notEmpty(data?“data“);
CheckUtils.notEmpty(key?“key“);
if(key.length!=16){
throw?new?RuntimeException(“Invalid?AES?key?length?(must?be?16?bytes)“);
}
try?{
SecretKeySpec?secretKey?=?new?SecretKeySpec(key?“AES“);?
byte[]?enCodeFormat?=?secretKey.getEncoded();
SecretKeySpec?seckey?=?new?SecretKeySpec(enCodeFormat?“AES“);
Cipher?cipher?=?Cipher.getInstance(ConfigureEncryptAndDecrypt.AES_ALGORITHM);//?創(chuàng)建密碼器
cipher.init(Cipher.DECRYPT_MODE?seckey);//?初始化
byte[]?result?=?cipher.doFinal(data);
return?result;?//?加密
}?catch?(Exception?e){
throw?new?RuntimeException(“decrypt?fail!“?e);
}
}

public?static?String?encryptTobase64(String?data?String?key){
try?{
byte[]?valueByte?=?encrypt(data.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING)?key.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING));
return?new?String(base64.encode(valueByte));
}?catch?(UnsupportedEncodingException?e)?{
throw?new?RuntimeException(“encrypt?fail!“?e);
}

}

public?static?String?decryptFrombase64(String?data?String?key){
try?{
byte[]?originalData?=?base64.decode(data.getBytes());
byte[]?valueByte?=?decrypt(originalData?key.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING));
return?new?String(valueByte?ConfigureEncryptAndDecrypt.CHAR_ENCODING);
}?catch?(UnsupportedEncodingException?e)?{
throw?new?RuntimeException(“decrypt?fail!“?e);
}
}

public?static?String?encryptWithKeybase64(String?data?String?key){
try?{
byte[]?valueByte?=?encrypt(data.getBytes(ConfigureEncryptAndDecrypt.CHAR_ENCODING)?base64.decode(key.getBytes()));
return?new?String(base64.encode(valueByte));
}?catch?(UnsupportedEncodingEx

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----

?????文件????????421??2016-04-21?17:32??encryption\.classpath

?????文件????????386??2016-04-21?17:28??encryption\.project

?????文件????????598??2016-04-21?17:28??encryption\.settings\org.eclipse.jdt.core.prefs

?????文件???????3628??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\AES.class

?????文件???????7960??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\base64.class

?????文件???????1825??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\Che001SignUtil.class

?????文件???????1424??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\CheckUtils.class

?????文件????????529??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\ConfigureEncryptAndDecrypt.class

?????文件???????9800??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\ConvertUtils.class

?????文件???????3888??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\Digest.class

?????文件???????2075??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\EncryptionUtil.class

?????文件????????620??2016-04-21?17:33??encryption\bin\com\cn\sec\rsa\EncryUtil$1.class

?????文件???????4262??2016-04-21?17:33??encryption\bin\com\cn\sec\rsa\EncryUtil.class

?????文件???????1065??2016-04-21?17:32??encryption\bin\com\cn\sec\rsa\RandomUtil.class

?????文件???????5227??2016-05-23?11:36??encryption\bin\com\cn\sec\rsa\RSA.class

?????文件???????2854??2016-05-23?11:27??encryption\bin\com\cn\sec\test\A.class

?????文件????????622??2016-05-23?11:24??encryption\bin\com\cn\sec\test\B$1.class

?????文件???????3457??2016-05-23?11:24??encryption\bin\com\cn\sec\test\B.class

?????文件???????1263??2016-05-23?11:00??encryption\bin\com\cn\sec\test\KeyGenerator.class

?????文件?????279193??2014-03-24?09:50??encryption\bin\commons-lang-2.5.jar

?????文件?????295771??2014-03-24?09:50??encryption\bin\fastjson-1.1.8.jar

?????文件?????124932??2014-03-24?09:50??encryption\bin\json-lib-2.1-jdk15.jar

?????文件???????4069??2016-04-21?17:30??encryption\src\com\cn\sec\rsa\AES.java

?????文件??????20565??2016-04-21?17:30??encryption\src\com\cn\sec\rsa\base64.java

?????文件???????1161??2016-04-21?17:32??encryption\src\com\cn\sec\rsa\Che001SignUtil.java

?????文件???????1139??2016-04-21?17:30??encryption\src\com\cn\sec\rsa\CheckUtils.java

?????文件????????259??2016-04-21?17:30??encryption\src\com\cn\sec\rsa\ConfigureEncryptAndDecrypt.java

?????文件??????10374??2016-04-21?17:30??encryption\src\com\cn\sec\rsa\ConvertUtils.java

?????文件???????4162??2016-04-21?17:30??encryption\src\com\cn\sec\rsa\Digest.java

?????文件???????1728??2016-04-21?17:30??encryption\src\com\cn\sec\rsa\EncryptionUtil.java

............此處省略26個(gè)文件信息

評(píng)論

共有 條評(píng)論