From 277633d9037f551a0a06b072d165effc3a2950b5 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Fri, 27 May 2022 17:24:40 +0800 Subject: [PATCH] fix: aes key needs 16 bytes https://github.com/gedoor/legado/pull/1902/commits/83a9971d661493f08b937cc6576c4604d55dcba7 --- app/src/main/java/io/legado/app/data/entities/BaseSource.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt index 50acc0492..05e1a6ec3 100644 --- a/app/src/main/java/io/legado/app/data/entities/BaseSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BaseSource.kt @@ -115,7 +115,7 @@ interface BaseSource : JsExtensions { */ fun getLoginInfo(): String? { try { - val key = AppConst.androidId.encodeToByteArray(0, 8) + val key = AppConst.androidId.encodeToByteArray(0, 16) val cache = CacheManager.get("userInfo_${getKey()}") ?: return null val encodeBytes = Base64.decode(cache, Base64.DEFAULT) val decodeBytes = EncoderUtils.decryptAES(encodeBytes, key) @@ -136,7 +136,7 @@ interface BaseSource : JsExtensions { */ fun putLoginInfo(info: String): Boolean { return try { - val key = (AppConst.androidId).encodeToByteArray(0, 8) + val key = (AppConst.androidId).encodeToByteArray(0, 16) val encodeBytes = EncoderUtils.encryptAES(info.toByteArray(), key) val encodeStr = Base64.encodeToString(encodeBytes, Base64.DEFAULT) CacheManager.put("userInfo_${getKey()}", encodeStr)