pull/1121/head
gedoor 3 years ago
parent 5baa083a8e
commit e82e92ba07
  1. 32
      app/src/main/java/io/legado/app/help/JsExtensions.kt

@ -443,10 +443,7 @@ interface JsExtensions {
* @param iv ECB模式的偏移向量 * @param iv ECB模式的偏移向量
*/ */
fun aesDecodeToByteArray( fun aesDecodeToByteArray(
str: String, str: String, key: String, transformation: String, iv: String
key: String,
transformation: String,
iv: String
): ByteArray? { ): ByteArray? {
return EncoderUtils.decryptAES( return EncoderUtils.decryptAES(
data = str.encodeToByteArray(), data = str.encodeToByteArray(),
@ -465,10 +462,7 @@ interface JsExtensions {
*/ */
fun aesDecodeToString( fun aesDecodeToString(
str: String, str: String, key: String, transformation: String, iv: String
key: String,
transformation: String,
iv: String
): String? { ): String? {
return aesDecodeToByteArray(str, key, transformation, iv)?.let { String(it) } return aesDecodeToByteArray(str, key, transformation, iv)?.let { String(it) }
} }
@ -482,10 +476,7 @@ interface JsExtensions {
*/ */
fun aesBase64DecodeToByteArray( fun aesBase64DecodeToByteArray(
str: String, str: String, key: String, transformation: String, iv: String
key: String,
transformation: String,
iv: String
): ByteArray? { ): ByteArray? {
return EncoderUtils.decryptBase64AES( return EncoderUtils.decryptBase64AES(
data = str.encodeToByteArray(), data = str.encodeToByteArray(),
@ -504,10 +495,7 @@ interface JsExtensions {
*/ */
fun aesBase64DecodeToString( fun aesBase64DecodeToString(
str: String, str: String, key: String, transformation: String, iv: String
key: String,
transformation: String,
iv: String
): String? { ): String? {
return aesBase64DecodeToByteArray(str, key, transformation, iv)?.let { String(it) } return aesBase64DecodeToByteArray(str, key, transformation, iv)?.let { String(it) }
} }
@ -520,8 +508,7 @@ interface JsExtensions {
* @param iv ECB模式的偏移向量 * @param iv ECB模式的偏移向量
*/ */
fun aesEncodeToByteArray( fun aesEncodeToByteArray(
data: String, key: String, transformation: String, data: String, key: String, transformation: String, iv: String
iv: String
): ByteArray? { ): ByteArray? {
return EncoderUtils.encryptAES( return EncoderUtils.encryptAES(
data.encodeToByteArray(), data.encodeToByteArray(),
@ -539,8 +526,7 @@ interface JsExtensions {
* @param iv ECB模式的偏移向量 * @param iv ECB模式的偏移向量
*/ */
fun aesEncodeToString( fun aesEncodeToString(
data: String, key: String, transformation: String, data: String, key: String, transformation: String, iv: String
iv: String
): String? { ): String? {
return aesEncodeToByteArray(data, key, transformation, iv)?.let { String(it) } return aesEncodeToByteArray(data, key, transformation, iv)?.let { String(it) }
} }
@ -553,8 +539,7 @@ interface JsExtensions {
* @param iv ECB模式的偏移向量 * @param iv ECB模式的偏移向量
*/ */
fun aesEncodeToBase64ByteArray( fun aesEncodeToBase64ByteArray(
data: String, key: String, transformation: String, data: String, key: String, transformation: String, iv: String
iv: String
): ByteArray? { ): ByteArray? {
return EncoderUtils.encryptAES2Base64( return EncoderUtils.encryptAES2Base64(
data.encodeToByteArray(), data.encodeToByteArray(),
@ -572,8 +557,7 @@ interface JsExtensions {
* @param iv ECB模式的偏移向量 * @param iv ECB模式的偏移向量
*/ */
fun aesEncodeToBase64String( fun aesEncodeToBase64String(
data: String, key: String, transformation: String, data: String, key: String, transformation: String, iv: String
iv: String
): String? { ): String? {
return aesEncodeToBase64ByteArray(data, key, transformation, iv)?.let { String(it) } return aesEncodeToBase64ByteArray(data, key, transformation, iv)?.let { String(it) }
} }

Loading…
Cancel
Save