Merge pull request #1916 from Xwite/master

fix: aes key needs 16 bytes
pull/1931/head
kunfei 2 years ago committed by GitHub
commit 5286384e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      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)

Loading…
Cancel
Save