From c83a31f52dfb7d436862cb3519a28cfc5651bbd5 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Wed, 15 Mar 2023 10:41:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/crypto/AsymmetricCrypto.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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))