加密常用加解密工具类(md5、sha、des、aes、rsa)

md5解密  时间:2021-01-31  阅读:()

常用加解密工具类MD5、 S HA、 DES、 AES、 RS A

加解密工具类实现了常用的加解密类。包括单向加密MD5、 SHA对称加密 DES、AES非对称加密 RS A

完整代码见 https://git.os china.net/bayern.c om/S ecureUtils.git同时提供ant打包脚本。

Cipher cipher=Cipher.getInstanc e(ALGORIT HM);cipher.init(Cipher.ENCRYPT_MODE,md5Key);return c ipher.doFinal(data);

@Overridepublic byte[]decrypt(byte[]data) throws Exc eptionif(s ecretKey==null | | .equals(s ecretKey))throw new Exc eption( scretKey need to exists

SecretKey md5Key=getKey(secretKey);

Cipher cipher=Cipher.getInstanc e(ALGORIT HM);cipher.init(Cipher.DECRYPT_MODE,md5Key);return c ipher.doFinal(data);

PrivateKey rsaPrivateKey=getRS APrivateKey();

Cipher cipher=Cipher.getInstanc e(ALGORIT HM);cipher.init(Cipher.ENCRYPT_MODE, rsaPrivateKey);return c ipher.doFinal(data);

@Overridepublic byte[]decrypt(byte[]data) throws Exc eption

PrivateKey rsaPrivateKey=getRS APrivateKey();

Cipher cipher=Cipher.getInstanc e(ALGORIT HM);cipher.init(Cipher.DECRYPT_MODE, rsaPrivateKey);return c ipher.update(data);

*使用私钥对数据进行签名

*@param data

*@r eturn

*@throw s Exc eptionpublic String sign(byte[]data) throws Exc eption

PrivateKey rsaPrivateKey=getRS APrivateKey();

Signature signature=Signature.getInstanc e(SIGN_ALGORIT HM);s ignature.initS ign(rs aPrivateKey);s ignature.update(data);return enc oder(s ignature.s ign());

RSA非对称加密。公钥加密公钥解密公钥校验签名

@Overridepublic byte[] encrypt(byte[]data) throws Exc eptionif(public Key==null | | .equals(public Key))throw new Exc eption(publicKey is need exists

PublicKey rsaPublicKey=getRSAPublic Key(public Key);

Cipher cipher=Cipher.getInstanc e(ALGORIT HM);cipher.init(Cipher.ENCRYPT_MODE, rsaPublicKey);return c ipher.doFinal(data);

@Overridepublic byte[]decrypt(byte[]data) throws Exc eptionif(public Key==null | | .equals(public Key))throw new Exc eption(publicKey is need exists

PublicKey rsaPublicKey=getRSAPublic Key(public Key);

Cipher cipher=Cipher.getInstanc e(ALGORIT HM);cipher.init(Cipher.DECRYPT_MODE, rsaPublicKey);return c ipher.doFinal(data);

*使用公钥校验签名

*@param data

*@param sign

*@r eturn

*@throw s Exc eptionpublic boolean verifySign(byte[]data,String sign) throws Exceptionif(public Key==null | | .equals(public Key))throw new Exc eption(publicKey is need exists

PublicKey rsaPublicKey=getRSAPublic Key(public Key);

Signature signature=Signature.getInstanc e(SIGN_ALGORIT HM);s ignature.initVerify(rs aPublic Key);s ignature.update(data);return s ignature.verify(dec oder(s ign));

}

香港、美国、日本、韩国、新加坡、越南、泰国、加拿大、英国、德国、法国等VPS,全球独立服务器99元起步 湘南科技

全球独立服务器、站群多IP服务器、VPS(哪个国家都有),香港、美国、日本、韩国、新加坡、越南、泰国、加拿大、英国、德国、法国等等99元起步,湘南科技郴州市湘南科技有限公司官方网址:www.xiangnankeji.cn产品内容:全球独立服务器、站群多IP服务器、VPS(哪个国家都有),香港、美国、日本、韩国、新加坡、越南、泰国、加拿大、英国、德国、法国等等99元起步,湘南科技VPS价格表:独立服...

7月RAKsmart独立服务器和站群服务器多款促销 G口不限量更低

如果我们熟悉RAKsmart商家促销活动的应该是清楚的,每个月的活动看似基本上一致。但是有一些新品或者每个月还是有一些各自的特点的。比如七月份爆款I3-2120仅30美金、V4新品上市,活动期间5折、洛杉矶+硅谷+香港+日本站群恢复销售、G口不限流量服务器比六月份折扣力度更低。RAKsmart 商家这个月依旧还是以独立服务器和站群服务器为主。当然也包括有部分的低至1.99美元的VPS主机。第一、I...

老薛主机入门建站月付34/月,年付345元,半价香港VPS主机

老薛主机怎么样?老薛主机这个商家有存在有一些年头。如果没有记错的话,早年老薛主机是做虚拟主机业务的,还算不错在异常激烈的市场中生存到现在,应该算是在众多商家中早期积累到一定的用户群的,主打小众个人网站业务所以能持续到现在。这不,站长看到商家有在进行夏季促销,比如我们很多网友可能有需要的香港vps主机季度及以上可以半价优惠,如果有在选择不同主机商的香港机房的可以看看老薛主机商家的香港vps。点击进入...

md5解密为你推荐
唐人社美国10次啦我们新婚一天做爱十次正常吗p图软件哪个好用什么p图软件好用?不是p人照片的那种软件p图软件哪个好用什么P图软件好用?麒麟990和骁龙865哪个好骁龙八65和麒麟990谁强一点?录屏软件哪个好有什么好用的录制屏幕的软件吗苹果手机助手哪个好最新版iphone助手 PP助手好用吗?游戏盒子哪个好lol游戏盒子哪个好电陶炉和电磁炉哪个好电陶炉和电磁炉哪个好?主要是炒菜,爆炒。尼康和佳能单反哪个好入门的单反相机 佳能和尼康哪个好?速腾和朗逸哪个好大众速腾和朗逸哪个比较好?家用!
太原域名注册 西部数码vps 如何查询域名备案号 万网域名证书查询 主机测评 特价空间 godaddy优惠券 win8升级win10正式版 美国php空间 网站实时监控 网通服务器ip 服务器架设 中国电信测速112 微信收钱 工作站服务器 域名接入 流量计费 爱奇艺vip免费试用7天 上海服务器 卡巴斯基免费试用版 更多