|
|
@ -761,6 +761,76 @@ interface JsExtensions { |
|
|
|
).decryptStr(data) |
|
|
|
).decryptStr(data) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* AES加密并转为Base64,算法参数经过Base64加密 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param data 被加密的字符串 |
|
|
|
|
|
|
|
* @param key Base64后的密钥 |
|
|
|
|
|
|
|
* @param mode 模式 |
|
|
|
|
|
|
|
* @param padding 补码方式 |
|
|
|
|
|
|
|
* @param iv Base64后的加盐 |
|
|
|
|
|
|
|
* @return 加密后的Base64 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun aesEncodeArgsBase64Str( |
|
|
|
|
|
|
|
data: String, |
|
|
|
|
|
|
|
key: String, |
|
|
|
|
|
|
|
mode: String, |
|
|
|
|
|
|
|
padding: String, |
|
|
|
|
|
|
|
iv: String |
|
|
|
|
|
|
|
): String? { |
|
|
|
|
|
|
|
return AES( |
|
|
|
|
|
|
|
mode, |
|
|
|
|
|
|
|
padding, |
|
|
|
|
|
|
|
Base64.decode(key, Base64.NO_WRAP), |
|
|
|
|
|
|
|
Base64.decode(iv, Base64.NO_WRAP) |
|
|
|
|
|
|
|
).encryptBase64(data) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 3DES加密并转为Base64 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param data 被加密的字符串 |
|
|
|
|
|
|
|
* @param key 密钥 |
|
|
|
|
|
|
|
* @param mode 模式 |
|
|
|
|
|
|
|
* @param padding 补码方式 |
|
|
|
|
|
|
|
* @param iv 加盐 |
|
|
|
|
|
|
|
* @return 加密后的Base64 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun tripleDESEncodeBase64Str( |
|
|
|
|
|
|
|
data: String, |
|
|
|
|
|
|
|
key: String, |
|
|
|
|
|
|
|
mode: String, |
|
|
|
|
|
|
|
padding: String, |
|
|
|
|
|
|
|
iv: String |
|
|
|
|
|
|
|
): String? { |
|
|
|
|
|
|
|
return DESede(mode, padding, key.toByteArray(), iv.toByteArray()).encryptBase64(data) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 3DES加密并转为Base64,算法参数经过Base64加密 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param data 被加密的字符串 |
|
|
|
|
|
|
|
* @param key Base64后的密钥 |
|
|
|
|
|
|
|
* @param mode 模式 |
|
|
|
|
|
|
|
* @param padding 补码方式 |
|
|
|
|
|
|
|
* @param iv Base64后的加盐 |
|
|
|
|
|
|
|
* @return 加密后的Base64 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
fun tripleDESEncodeArgsBase64Str( |
|
|
|
|
|
|
|
data: String, |
|
|
|
|
|
|
|
key: String, |
|
|
|
|
|
|
|
mode: String, |
|
|
|
|
|
|
|
padding: String, |
|
|
|
|
|
|
|
iv: String |
|
|
|
|
|
|
|
): String? { |
|
|
|
|
|
|
|
return DESede( |
|
|
|
|
|
|
|
mode, |
|
|
|
|
|
|
|
padding, |
|
|
|
|
|
|
|
Base64.decode(key, Base64.NO_WRAP), |
|
|
|
|
|
|
|
Base64.decode(iv, Base64.NO_WRAP) |
|
|
|
|
|
|
|
).encryptBase64(data) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 生成摘要,并转为16进制字符串 |
|
|
|
* 生成摘要,并转为16进制字符串 |
|
|
|
* |
|
|
|
* |
|
|
|