Xwite 3 anni fa
parent
commit
2b4785a0f5

+ 1 - 1
app/src/main/assets/help/jsHelp.md

@@ -219,7 +219,7 @@ java.createAsymmetricCrypto(transformation)
 //解密为ByteArray String
 //解密为ByteArray String
 cipher.decrypt(data,  usePublicKey: Boolean? = true
 cipher.decrypt(data,  usePublicKey: Boolean? = true
 )
 )
-cipher.decryptStr(data: String!!,  usePublicKey: Boolean? = true
+cipher.decryptStr(data, usePublicKey: Boolean? = true
 )
 )
 //加密为ByteArray Base64字符 HEX字符
 //加密为ByteArray Base64字符 HEX字符
 cipher.encrypt(data,  usePublicKey: Boolean? = true
 cipher.encrypt(data,  usePublicKey: Boolean? = true

+ 3 - 1
app/src/main/java/io/legado/app/help/crypto/AsymmetricCrypto.kt

@@ -41,9 +41,11 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
     }
     }
 
 
     @JvmOverloads
     @JvmOverloads
-    fun decryptStr(data: String, usePublicKey: Boolean? = true): String {
+    fun decryptStr(data: Any, usePublicKey: Boolean? = true): String {
         return when {
         return when {
+            data is ByteArray -> String(decrypt(data, getKeyType(usePublicKey)))
             data is String -> decryptStr(data, getKeyType(usePublicKey))
             data is String -> decryptStr(data, getKeyType(usePublicKey))
+            data is InputStream -> String(decrypt(data, getKeyType(usePublicKey)))
             else -> throw IllegalArgumentException("Unexpected input type")
             else -> throw IllegalArgumentException("Unexpected input type")
         }
         }
     }
     }

+ 1 - 1
app/src/main/java/io/legado/app/help/crypto/README.md

@@ -8,7 +8,7 @@ fun setPrivateKey(key: ByteArray): T
 fun setPrivateKey(key: String): T
 fun setPrivateKey(key: String): T
 
 
 fun decrypt(data: Any, usePublicKey: Boolean? = true): ByteArray?
 fun decrypt(data: Any, usePublicKey: Boolean? = true): ByteArray?
-fun decryptStr(data: String, usePublicKey: Boolean? = true): String?
+fun decryptStr(data: Any, usePublicKey: Boolean? = true): String?
 
 
 fun encrypt(data: Any, usePublicKey: Boolean? = true): ByteArray?
 fun encrypt(data: Any, usePublicKey: Boolean? = true): ByteArray?
 fun encryptHex(data: Any, usePublicKey: Boolean? = true): String?
 fun encryptHex(data: Any, usePublicKey: Boolean? = true): String?