|
|
|
@ -142,54 +142,6 @@ $.exports = { |
|
|
|
|
"一级": 一级, |
|
|
|
|
"二级": 二级, |
|
|
|
|
"公共": 公共, |
|
|
|
|
"属性": 属性 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$.exports.imageDecrypt = function() { |
|
|
|
|
const FileUtil = com.example.hikerview.utils.FileUtil; |
|
|
|
|
const Cipher = Cipher = javax.crypto.Cipher; |
|
|
|
|
const IvParameterSpec = javax.crypto.spec.IvParameterSpec; |
|
|
|
|
const SecretKeySpec = javax.crypto.spec.SecretKeySpec; |
|
|
|
|
function hexStringToBytes(cipherText) { |
|
|
|
|
cipherText = String(cipherText); |
|
|
|
|
let str = cipherText.toLowerCase(); |
|
|
|
|
let length = str.length; |
|
|
|
|
let bArr = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, length / 2); |
|
|
|
|
for (let i = 0, o = 0; i < length; i += 2, o++) { |
|
|
|
|
let a = str[i + 1], |
|
|
|
|
b = str[i]; |
|
|
|
|
if (b != "0") { |
|
|
|
|
a = b + a; |
|
|
|
|
} |
|
|
|
|
let hexInt = java.lang.Integer.parseInt(new java.lang.String(a), 16); |
|
|
|
|
let inty = hexInt > 127 ? hexInt - 255 - 1 : hexInt; |
|
|
|
|
bArr[o] = inty; |
|
|
|
|
} |
|
|
|
|
return bArr; |
|
|
|
|
} |
|
|
|
|
function getBytes(str) { |
|
|
|
|
let bytes; |
|
|
|
|
if (kiType === "Base64") { |
|
|
|
|
bytes = _base64.decode(str, _base64.NO_WRAP); |
|
|
|
|
} else if (kiType === "Hex") { |
|
|
|
|
bytes = hexStringToBytes(str); |
|
|
|
|
} else { |
|
|
|
|
bytes = String(str).getBytes("UTF-8"); |
|
|
|
|
} |
|
|
|
|
return bytes; |
|
|
|
|
} |
|
|
|
|
kiType = kiType || "String"; |
|
|
|
|
mode = mode || 'AES/CBC/PKCS5Padding'; |
|
|
|
|
key = getBytes(key); |
|
|
|
|
iv = getBytes(iv); |
|
|
|
|
function decryptData(cipherText) { |
|
|
|
|
let secretKeySpec = new SecretKeySpec(key, "AES"); |
|
|
|
|
let ivParameterSpec = new IvParameterSpec(iv); |
|
|
|
|
let cipher = Cipher.getInstance(mode); |
|
|
|
|
cipher.init(2, secretKeySpec, ivParameterSpec); |
|
|
|
|
return cipher.doFinal(cipherText); |
|
|
|
|
} |
|
|
|
|
let bytes = FileUtil.toBytes(input); |
|
|
|
|
bytes = decryptData(bytes); |
|
|
|
|
return FileUtil.toInputStream(bytes); |
|
|
|
|
"属性": 属性, |
|
|
|
|
"imageDecrypt": 图片解密 |
|
|
|
|
} |