android des加密和解密
来源:互联网 发布:linux snmp服务 编辑:程序博客网 时间:2024/05/08 08:21
加密方法:
public String encryptDES(String encryptString, String encryptKey) throws Exception {IvParameterSpec zeroIv = new IvParameterSpec(new byte[8]);SecretKeySpec key = new SecretKeySpec(encryptKey.getBytes(), "DES");Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");cipher.init(Cipher.ENCRYPT_MODE, key, zeroIv);byte[] encryptedData = cipher.doFinal(encryptString.getBytes());return new BASE64Encoder().encode(encryptedData);}解密方法:
public String decryptDES(String decryptString, String decryptKey) throws Exception {byte[] byteMi = new BASE64Decoder().decodeBuffer(decryptString);IvParameterSpec zeroIv = new IvParameterSpec(new byte[8]);SecretKeySpec key = new SecretKeySpec(decryptKey.getBytes(), "DES");Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");cipher.init(Cipher.DECRYPT_MODE, key, zeroIv);byte decryptedData[] = cipher.doFinal(byteMi);return new String(decryptedData);}
所需要的jar包在附件中
- android des加密和解密
- Android DES加密解密
- android des 加密解密
- Android DES加密解密
- android DES加密解密
- Android--DES加密解密
- DES加密和解密
- DES加密和解密
- Des加密和解密
- DES加密和解密
- DES解密和加密
- DES加密和解密
- des加密和解密
- DES加密和解密
- Android DES加密的CBC和ECB加密解密模式
- Android DES加密解密算法
- 【Android】DES加密与解密
- android 3DES加密解密
- 一些连接
- C++标准库和标准模板库
- bbg# 2013-12-6
- 如何正确在windows和ubuntu双系统中删除ubuntu系统
- DELPHI使用UniDAC执行储存过程
- android des加密和解密
- 用eclipse运行和部署myeclipse项目
- 几个有意思的算法题
- ASP.NET MVC4 IN ACTION学习笔记-第六波[Ajax in ASP.NET MVC][3/3]
- Xml基础详解和DTD验证
- 程序员面试之葵花宝典
- [转]Struts2.3 + Spring3.2 整合
- Nessus (TBD)
- 通过词找到对应的文章类别