package Lion.Security.Cryptography;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
public class des {
private String Algorithm = "DES";
private KeyGenerator keygen;
private SecretKey deskey;
private Cipher c;
private byte[] cipherByte;
public des() {
init();
}
public void init() {
Security.addProvider(new com.sun.crypto.provider.SunJCE());
try {
keygen = KeyGenerator.getInstance(Algorithm);
deskey = keygen.generateKey();
c = Cipher.getInstance(Algorithm);
}
catch(NoSuchAlgorithmException ex){
ex.printStackTrace();
}
catch(NoSuchPaddingException ex){
ex.printStackTrace();
}
}
public byte[] createEncryptor(String str) {
try {
c.init(Cipher.ENCRYPT_MODE, deskey);
cipherByte = c.doFinal(str.getBytes());
}
catch(java.security.InvalidKeyException ex){
ex.printStackTrace();
}
catch(javax.crypto.BadPaddingException ex){
ex.printStackTrace();
}
catch(javax.crypto.IllegalBlockSizeException ex){
ex.printStackTrace();
return cipherByte;
}
return cipherByte;
}
public String createDecryptor(byte[] buff) {
try {
c.init(Cipher.DECRYPT_MODE, deskey);
cipherByte = c.doFinal(buff);
}
catch(java.security.InvalidKeyException ex){
ex.printStackTrace();
}
catch(javax.crypto.BadPaddingException ex){
ex.printStackTrace();
}
catch(javax.crypto.IllegalBlockSizeException ex){
ex.printStackTrace();
}
return (new String(cipherByte));
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jsp加密解密问题.rar
共8个文件
classpath:1个
project:1个
mymetadata:1个
5星 · 超过95%的资源 需积分: 10 63 下载量 140 浏览量
2008-11-25
21:38:08
上传
评论
收藏 5KB RAR 举报
温馨提示
jsp加密解密问题.rar url参数加密解决
资源推荐
资源详情
资源评论
收起资源包目录
jsp加密解密问题.rar (8个子文件)
aa
.project 1KB
.mymetadata 279B
WebRoot
WEB-INF
web.xml 375B
lib
classes
Lion
Security
Cryptography
des.class 2KB
META-INF
MANIFEST.MF 39B
des.jsp 1KB
.myeclipse
src
Lion
Security
Cryptography
des.java 3KB
.classpath 340B
共 8 条
- 1
资源评论
- hnzkclj2013-05-31不是我想要的,我是想要直接对url加密的
juicewall
- 粉丝: 21
- 资源: 228
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功