这次给大家带来如何使用java 3DES加解密,使用java 3DES加解密的注意事项有哪些,下面就是实战案例,一起来看一下。
<pre class="brush:php;toolbar:false">Java写的加密解密算法及调用范例
1、.JAVA算法范例
package Common.JUtility;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
public class EncryptUtils {
/// <summary>
/// 3des解码
/// </summary>
/// <param>待解密字符串
/// <param>原始密钥字符串
/// <returns></returns>
public static String Decrypt3DES(String value, String key) throws Exception {
byte[] b = decryptMode(GetKeyBytes(key), Base64.decode(value));
return new String(b);
}
/// <summary>
/// 3des加密
/// </summary>
/// <param>待加密字符串
/// <param>原始密钥字符串
/// <returns></returns>
public static String Encrypt3DES(String value, String key) throws Exception {
String str = byte2Base64(encryptMode(GetKeyBytes(key), value.getBytes()));
return str;
}
//计算24位长的密码byte值,首先对原始密钥做MD5算hash值,再用前8位数据对应补全后8位
public static byte[] GetKeyBytes(String strKey) throws Exception {
if (null == strKey || strKey.length() <p>相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网<a href="http://www.php.cn/html5/html5-3-mip-normal.html" target="_blank">其它</a>相关文章!</p><p>推荐阅读:</p><p><a href="http://www.php.cn/html5-tutorial-400609.html" target="_blank">移动端WEB开发中click,touch,tap事件使用详解</a><br></p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill12680" title="JavaScript 开发专家"><img
src="https://img.php.cn/upload/skill/001/246/273/6adaf20dee630206.jpg" alt="JavaScript 开发专家" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/skill12680" title="JavaScript 开发专家" class="overflowclass">JavaScript 开发专家</a>
<p class="overflowclass">掌握包含 ES6+、异步模式和 Node.js API 的现代 JavaScript。处理 Promise、事件循环和浏览器/Node 兼容性。在 JavaSc</p>
</div>
<a rel="nofollow" href="/xiazai/skill12680" title="JavaScript 开发专家" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div><p><a href="http://www.php.cn/html5-tutorial-400608.html" target="_blank">REM相对单位使用案例分享</a><br></p>
Java免费学习笔记:立即使用
解锁 Java 大师之旅:从入门到精通的终极指南










