diff --git a/app/src/main/java/io/legado/app/help/crypto/AsymmetricCrypto.kt b/app/src/main/java/io/legado/app/help/crypto/AsymmetricCrypto.kt index 2bbd059ba..7da81dc49 100644 --- a/app/src/main/java/io/legado/app/help/crypto/AsymmetricCrypto.kt +++ b/app/src/main/java/io/legado/app/help/crypto/AsymmetricCrypto.kt @@ -32,7 +32,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) { @JvmOverloads fun decrypt(data: Any, usePublicKey: Boolean? = true): ByteArray { - return { + return when { data is ByteArray -> decrypt(data, getKeyType(usePublicKey)) data is String -> decrypt(data, getKeyType(usePublicKey)) data is InputStream -> decrypt(data, getKeyType(usePublicKey)) @@ -42,7 +42,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) { @JvmOverloads fun decryptStr(data: Any, usePublicKey: Boolean? = true): String { - return { + return when { data is ByteArray -> decryptStr(data, getKeyType(usePublicKey)) data is String -> decryptStr(data, getKeyType(usePublicKey)) data is InputStream -> decryptStr(data, getKeyType(usePublicKey)) @@ -52,7 +52,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) { @JvmOverloads fun encrypt(data: Any, usePublicKey: Boolean? = true): ByteArray { - return { + return when { data is ByteArray -> encrypt(data, getKeyType(usePublicKey)) data is String -> encrypt(data, getKeyType(usePublicKey)) data is InputStream -> encrypt(data, getKeyType(usePublicKey)) @@ -62,7 +62,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) { @JvmOverloads fun encryptHex(data: Any, usePublicKey: Boolean? = true): String { - return { + return when { data is ByteArray -> encryptHex(data, getKeyType(usePublicKey)) data is String -> encryptHex(data, getKeyType(usePublicKey)) data is InputStream -> encryptHex(data, getKeyType(usePublicKey)) @@ -72,7 +72,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) { @JvmOverloads fun encryptBase64(data: Any, usePublicKey: Boolean? = true): String { - return { + return when { data is ByteArray -> encryptBase64(data, getKeyType(usePublicKey)) data is String -> encryptBase64(data, getKeyType(usePublicKey)) data is InputStream -> encryptBase64(data, getKeyType(usePublicKey))