fix: aes key needs 16 bytes

83a9971d66
pull/1916/head
Xwite 3 years ago
parent 0a08522ae6
commit 277633d903
  1. 4
      app/src/main/java/io/legado/app/data/entities/BaseSource.kt

@ -115,7 +115,7 @@ interface BaseSource : JsExtensions {
*/ */
fun getLoginInfo(): String? { fun getLoginInfo(): String? {
try { try {
val key = AppConst.androidId.encodeToByteArray(0, 8) val key = AppConst.androidId.encodeToByteArray(0, 16)
val cache = CacheManager.get("userInfo_${getKey()}") ?: return null val cache = CacheManager.get("userInfo_${getKey()}") ?: return null
val encodeBytes = Base64.decode(cache, Base64.DEFAULT) val encodeBytes = Base64.decode(cache, Base64.DEFAULT)
val decodeBytes = EncoderUtils.decryptAES(encodeBytes, key) val decodeBytes = EncoderUtils.decryptAES(encodeBytes, key)
@ -136,7 +136,7 @@ interface BaseSource : JsExtensions {
*/ */
fun putLoginInfo(info: String): Boolean { fun putLoginInfo(info: String): Boolean {
return try { return try {
val key = (AppConst.androidId).encodeToByteArray(0, 8) val key = (AppConst.androidId).encodeToByteArray(0, 16)
val encodeBytes = EncoderUtils.encryptAES(info.toByteArray(), key) val encodeBytes = EncoderUtils.encryptAES(info.toByteArray(), key)
val encodeStr = Base64.encodeToString(encodeBytes, Base64.DEFAULT) val encodeStr = Base64.encodeToString(encodeBytes, Base64.DEFAULT)
CacheManager.put("userInfo_${getKey()}", encodeStr) CacheManager.put("userInfo_${getKey()}", encodeStr)

Loading…
Cancel
Save