j9九游会登录/ 云商店/ / / / / / isv server解密手机号和邮箱
更新时间:2025-11-13 gmt 08:00

isv server解密手机号和邮箱-j9九游会登录

代码调用如下图所示。

/**
*
* 解密手机号码或邮箱
* @param key 密钥* @param str 密文
* @param encryptlength 加密长度
* @return 解密结果
*/
public static string decryptmobilephoneoremail(string key, string str, int encryptlength)
{
if(null != str && str.length() > 16)
{
string iv = str.substring(0, 16);
string encryptstr = str.substring(16);
string result = null;
try
{
result = decryptaescbcencode(encryptstr,
key,
iv,
encryptlength);
}
catch (invalidkeyexception | nosuchalgorithmexception
| nosuchpaddingexception | invalidalgorithmparameterexception
| illegalblocksizeexception | badpaddingexception e)
{
//todo:异常处理
}
return result;
}
return null;
}
/**
* 解密aes cbc
* @param content 原文
* @param key 密钥* @param iv 盐值
* @return 解密结果
* @throws badpaddingexception
* @throws illegalblocksizeexception
* @throws invalidalgorithmparameterexception
* @throws nosuchpaddingexception
* @throws nosuchalgorithmexception
* @throws invalidkeyexception
*/
public static string decryptaescbcencode(string content, string key,
string iv, int encrypttype) throws invalidkeyexception, nosuchalgorithmexception, nosuchpaddingexception, invalidalgorithmparameterexception, illegalblocksizeexception, badpaddingexception
{
if (stringutils.isempty(content) || stringutils.isempty(key)
|| stringutils.isempty(iv))
{
return null;
}
return new string(decryptaescbc(base64.decodebase64(content.getbytes()),
key.getbytes(),
iv.getbytes(),encrypttype));
}
public static byte[] decryptaescbc(byte[] content, byte[] keybytes,
byte[] iv, int encrypttype) throws nosuchalgorithmexception, nosuchpaddingexception, invalidkeyexception, invalidalgorithmparameterexception, illegalblocksizeexception, badpaddingexception
{
keygenerator keygenerator = keygenerator.getinstance("aes");
securerandom securerandom = securerandom.getinstance("sha1prng");
securerandom.setseed(keybytes);
keygenerator.init(encrypttype, securerandom);
secretkey key = keygenerator.generatekey();
cipher cipher = cipher.getinstance("aes/cbc/pkcs5padding");
cipher.init(cipher.decrypt_mode, key, new ivparameterspec(iv));
byte[] result = cipher.dofinal(content);
return result;
}

相关文档

网站地图