常用加解密工具类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));
}
cmivps香港VPS带来了3个新消息:(1)双向流量改为单向流量,相当于流量间接扩大一倍;(2)Hong Kong 2T、Hong Kong 3T、Hong Kong 无限流量,这三款VPS开始支持Windows系统,如果需要中文版Windows系统请下单付款完成之后发ticket要求官方更改即可;(3)全场7折年付、8折月付优惠,优惠码有效期一个月!官方网站:https://www.cmivp...
今年1月的时候Hosteons开始提供1Gbps端口KVM架构VPS,目前商家在LET发布消息,到本月30日之前,用户下单洛杉矶/纽约/达拉斯三个地区机房KVM主机可以从1Gbps免费升级到10Gbps端口,最低年付仅21美元起。Hosteons是一家成立于2018年的国外VPS主机商,主要提供VPS、Hybrid Dedicated Servers及独立服务器租用等,提供IPv4+IPv6,支持...
商家介绍:创梦云是来自国内的主机销售商,成立于2018年4月30日,创梦云前期主要从事免备案虚拟主机产品销售,现在将提供5元挂机宝、特惠挂机宝、香港云服务器、美国云服务器、低价挂机宝等产品销售。主打高性价比高稳定性挂机宝、香港云服务器、美国云服务器、香港虚拟主机、美国虚拟主机。官方网站:http://cmy0.vnetdns.com本次促销产品:地区CPU内存硬盘带宽价格购买地址香港特价云服务器1...