java加密解密工具类】的更多相关文章

package com.founder.mrp.util; import java.nio.charset.StandardCharsets; import java.security.Key; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import com.founder.mrp.web.jsonEntity.AccountJson; /** * 加密解密类 * @author xiongzq * *…
最近发现了一个加密解密的好例子,很方便使用,可以作为平时开发的工具集,记录一下. package com.sh.springboottdemo2.util; import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.Mac; import javax.crypto.S…
使用Apache commons codec类Base64进行加密解密 maven依赖 <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.6</version> </dependency> 代码实现 package com.ljq.durian.common.util;…
/// <summary> /// .Net加密解密帮助类 /// </summary> public class NetCryptoHelper { #region des实现 /// <summary> /// Des默认密钥向量 /// </summary> public static byte[] DesIv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF }; /// <summary&g…
一个Java版的DES加密工具类,能够用来进行网络传输数据加密,保存password的时候进行加密. import java.security.Key; import java.security.spec.AlgorithmParameterSpec; import javax.crypto.Cipher; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESKeySpec; import javax.crypto.…
package club.codeapes.common.utils; import org.springframework.util.Base64Utils; import javax.crypto.Cipher;import javax.crypto.KeyGenerator;import javax.crypto.SecretKey;import javax.crypto.spec.SecretKeySpec;import java.security.NoSuchAlgorithmExce…
最近在做des的双对称加密解密,特此记录一下. des对称加密,是一种比较传统的加密方式,其加密运算.解密运算使用的是同样的密钥,信息的发送者和信息的接收者在进行信息的传输与处理时,必须共同持有该密码,是一种对称加密算法. 先上两个方法:加密与解密. public String encryptDes(String data,String key) throws Exception { //使用原始密钥数据创建DESKeySpec对象 DESedeKeySpec dks = new DESedeK…
在工作中经常遇到需要加密.解密的场景.例如用户的手机号等信息,在保存到数据库的过程中,需要对数据进行加密.取出时进行解密. public class DEStool { private String sKey; public DEStool() { //默认构造函数提供默认密钥 sKey = "des@#$12"; } public DEStool(String securityKey) { ) { throw new IllegalArgumentException("密钥…
此类主要用于加密与解密,采用128位ECB模式,PKCS5Padding填充补位. 可使用方法为加密返回二进制encryptBin(content, key).加密返回十六进制encryptHex(content, key).二进制内容解密decryptBin(content, key).十六进制内容解密decryptHex(content, key). content是需要加密的字符串,key是密钥,随意一个字符串. package com.test; import java.io.Unsup…
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.security.Key; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.CipherInputStream;…
public class MLDUtil { public static Key DEFAULT_KEY = null; public static final String DEFAULT_SECRET_KEY1 = "?:P)(OL><KI*&UJMNHY^%TGBVFR$#EDCXSW@!QAZ"; public static final String DEFAULT_SECRET_KEY2 = "1qaz2wsx3edc4rfv5tgb6yhn7u…
#import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface Helpers : NSObject @property(nonatomic,strong)NSDateFormatter *h_dateFormatter; @property(nonatomic,strong)NSDateComponents *h_components; +(BOOL)strIsEmty:(NSString *)str; +…
/** * RSA算法加密/解密工具类 */ public class RSAUtils { private static final Logger LOGGER = LoggerFactory.getLogger(RSAUtils.class); /** 算法名称 */ private static final String ALGORITHM = "RSA"; /** 默认密钥大小 */ private static final int KEY_SIZE = 1024; /** 用…
package com.geostar.gfstack.cas.util; import org.apache.commons.codec.binary.Base64; import javax.crypto.Cipher; import java.security.*; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security…
本人手写已测试,大家可以参考使用 package com.mirana.frame.utils.encrypt; import com.mirana.frame.constants.SysConstants; import com.mirana.frame.utils.RandomUtils; import com.mirana.frame.utils.SysPropUtils; import com.mirana.frame.utils.encrypt.enumtype.AESMode; im…
原理 对于任意长度的明文,AES首先对其进行分组,每组的长度为128位.分组之后将分别对每个128位的明文分组进行加密. 对于每个128位长度的明文分组的加密过程如下:     (1)将128位AES明文分组放入状态矩阵中.     (2)AddRoundKey变换:对状态矩阵进行AddRoundKey变换,与膨胀后的密钥进行异或操作(密钥膨胀将在实验原理七中详细讨论).     (3)10轮循环:AES对状态矩阵进行了10轮类似的子加密过程.前9轮子加密过程中,每一轮子加密过程包括4种不同的变…
AES加密.解密工具类代码如下: package com.util; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import javax.crypt…
该工具可以使用exe4j来打包成exe工具(如何打包自己百度) 先上截图功能 运行main方法后,会弹出如下窗口 输入密文 然后点击解密,在点格式化 代码分享 package tools;import java.awt.BorderLayout;import java.awt.Color;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.StringWriter;import…
Java 加密解密之消息摘要算法(MD5 SHA MAC) 消息摘要 消息摘要(Message Digest)又称为数字摘要(Digital Digest). 它是一个唯一相应一个消息或文本的固定长度的值,它由一个单向Hash加密函数对消息进行作用而产生.假设消息在途中改变了.则接收者通过对收到消息的新产生的摘要与原摘要比較.就可知道消息是否被改变了.因此消息摘要保证了消息的完整性.消息摘要採用单向Hash 函数将需加密 的明文"摘要"成一串128bit的密文.这一串密文亦称为数字指纹…
从数据安全谈起       当你使用网银时,是否担心你的银行卡会被盗用?     当你和朋友用QQ进行聊天时,是否担心你的隐私会被泄露?     作为开发者,编写安全的代码比编写优雅的代码更重要,因为安全是一切应用之根本!为了确保数据不被侵犯,数据加密/解密技术运用而生.    --摘录自<Java加密解密的艺术>       所以为了确保数据传输和数据存储的安全,我们可以通过特定的算法,将数据明文加密成复杂的密文.     众多的加密手段大致可以分为单项加密和双向加密.单项加密指通过对数据进…