有谁做过易宝IOS充值接口?现在我出现的问题是加密了,易宝那边解析不了,有人能帮我解决下么?
高分补偿!!
补充一下是128位的不是256的加密
试试看:
private static final String SECRET_AES = "AES";
private static final String SECRET_PATTERN_ECB = "AES/ECB/PKCS5Padding";
private static final String CODE = "UTF-8";
private static Cipher cipher;
private static SecretKeySpec secretKey;
/***
* AES加密
*
* @param value
* @param key
* @return
*/
public static byte[] _encode(String value, String key) {
try {
byte[] bs = key.getBytes(CODE);
secretKey = new SecretKeySpec(bs, SECRET_AES);
cipher = Cipher.getInstance(SECRET_PATTERN_ECB);
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
return cipher.doFinal(value.getBytes(CODE));
} catch (Exception e) {
return null;
}
}
/***
* AES解密
*
* @param value
* @param key
* @return
*/
public static String _decode(byte[] value, String key) {
try {
byte[] bs = key.getBytes(CODE);
secretKey = new SecretKeySpec(bs, SECRET_AES);
cipher = Cipher.getInstance(SECRET_PATTERN_ECB);
cipher.init(Cipher.DECRYPT_MODE, secretKey);
byte[] decrypt = cipher.doFinal(value);
return new String(decrypt);
} catch (Exception e) {
return null;
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。