更新时间: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; }
父主题:
相关文档
意见反馈
文档内容是否对您有帮助?
提交成功!非常感谢您的反馈,我们会继续努力做到更好!
您可在查看反馈及问题处理状态。
系统繁忙,请稍后重试
如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨