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

}

DMIT:香港国际线路vps,1.5GB内存/20GB SSD空间/4TB流量/1Gbps/KVM,$9.81/月

DMIT怎么样?DMIT是一家美国主机商,主要提供KVM VPS、独立服务器等,主要提供香港CN2、洛杉矶CN2 GIA等KVM VPS,稳定性、网络都很不错。支持中文客服,可Paypal、支付宝付款。2020年推出的香港国际线路的KVM VPS,大带宽,适合中转落地使用。现在有永久9折优惠码:July-4-Lite-10OFF,季付及以上还有折扣,非 中国路由优化;AS4134,AS4837 均...

DiyVM独立服务器:香港沙田服务器,5M带宽CN2线路,L5630*2/16G内存/120G SSD硬盘,499元/月

diyvm怎么样?diyvm商家VPS主机均2GB内存起步,三个地区机房可选,使用优惠码后每月69元起;DiyVM独立服务器开设在香港沙田电信机房,CN2线路,5M带宽,自动化开通上架,最低499元/月,配置是L5630*2/16G内存/120G SSD硬盘。DiyVM是一家成立于2009年的国人主机商,提供的产品包括VPS主机、独立服务器租用等,产品数据中心包括中国香港、日本大阪和美国洛杉矶等,...

野草云99元/月 ,香港独立服务器 E3-1230v2 16G 30M 299元/月 香港云服务器 4核 8G

野草云月末准备了一些促销,主推独立服务器,也有部分云服务器,价格比较有性价比,佣金是10%循环,如果有时间请帮我们推推,感谢!公司名:LucidaCloud Limited官方网站:https://www.yecaoyun.com/香港独立服务器:CPU型号内存硬盘带宽价格购买地址E3-1230v216G240GB SSD或1TB 企盘30M299元/月点击购买E5-265016G240GB SS...

md5解密为你推荐
免费阅读小说app哪个好有什么免费读小说的软件?录音软件哪个好手机录音软件哪个好用宝来和朗逸哪个好大众朗逸和宝来,哪个好点?ps软件哪个好什么PS软件好杰士邦和杜蕾斯哪个好安全套是杜蕾斯的好用还是杰士邦的好用?炒股软件哪个好用玩股票哪个软件好?电动牙刷哪个好电动牙刷和普通牙刷哪个好,有何区别?dns服务器故障DNS服务解析故障 怎么办铁通dns服务器地址嘉兴铁通的DNS服务器地址是多少?360云盘共享群360云盘共享群以后还有吗
我的世界服务器租用 vps交流 贝锐花生壳域名 韩国俄罗斯 l5639 空间出租 bgp双线 有奖调查 免费私人服务器 湖南idc 后门 云服务是什么意思 广州主机托管 北京主机托管 nic linuxvi命令 远程主机强迫关闭了一个现有的连接 台式机主机 魔兽世界服务器维护 dns服务器是什么 更多