加密常用加解密工具类(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));

}

月费$389,RackNerd美国大硬盘独立服务器

这次RackNerd商家提供的美国大硬盘独立服务器,数据中心位于洛杉矶multacom,可选Windows、Linux镜像系统,默认内存是64GB,也可升级至128GB内存,而且硬盘采用的是256G SSD系统盘+10个16TSAS数据盘,端口提供的是1Gbps带宽,每月提供200TB,且包含5个IPv4,如果有需要更多IP,也可以升级增加。CPU核心内存硬盘流量带宽价格选择2XE5-2640V2...

UCloud云服务器低至年59元

最近我们是不是在讨论较多的是关于K12教育的问题,培训机构由于资本的介入确实让家长更为焦虑,对于这样的整改我们还是很支持的。实际上,在云服务器市场中,我们也看到内卷和资本的力量,各大云服务商竞争也是相当激烈,更不用说个人和小公司服务商日子确实不好过。今天有看到UCloud发布的夏季促销活动,直接提前和双十一保价挂钩。这就是说,人家直接在暑假的时候就上线双十一的活动。早年的双十一活动会提前一周到十天...

轻云互联,香港云服务器折后22元/月 美国云服务器 1核 512M内存 15M带宽 折后19.36元/月

轻云互联成立于2018年的国人商家,广州轻云互联网络科技有限公司旗下品牌,主要从事VPS、虚拟主机等云计算产品业务,适合建站、新手上车的值得选择,香港三网直连(电信CN2GIA联通移动CN2直连);美国圣何塞(回程三网CN2GIA)线路,所有产品均采用KVM虚拟技术架构,高效售后保障,稳定多年,高性能可用,网络优质,为您的业务保驾护航。官方网站:点击进入广州轻云网络科技有限公司活动规则:1.用户购...

md5解密为你推荐
softbank手机中国哪里有softbank手机卖?316不锈钢和304哪个好请问316不锈钢和304不锈钢有什么区别?从外观如何辨别?电视直播软件哪个好电视直播软件哪个好英语词典哪个好英语词典哪个好杰士邦和杜蕾斯哪个好杰士邦的超薄款跟杜蕾斯的超薄款,哪个舒服点?加速器哪个好加速器哪个好用?雅思和托福哪个好考雅思和托福哪个好考一点美国国际集团美国AIG股票,值得长远投资吗??东莞电信网上营业厅东莞虎门电信营业厅dns服务器故障电脑dns服务器发生故障怎么解决
域名注册信息查询 服务器租用托管 mach5 59.99美元 2014年感恩节 suspended 监控宝 windows2003iso 权嘉云 免费美国空间 免费智能解析 多线空间 彩虹云 香港亚马逊 yundun 百度云加速 沈阳主机托管 lick 上海电信测速 国外网页代理 更多