This commit is contained in:
Horis
2024-07-12 22:46:05 +08:00
parent 773289b0db
commit 174c1e327c
@@ -2,6 +2,7 @@ package io.legado.app.help.crypto
import cn.hutool.crypto.KeyUtil
import cn.hutool.crypto.asymmetric.KeyType
import io.legado.app.utils.EncoderUtils
import java.io.InputStream
import cn.hutool.crypto.asymmetric.AsymmetricCrypto as HutoolAsymmetricCrypto
@@ -77,12 +78,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
@JvmOverloads
fun encryptBase64(data: Any, usePublicKey: Boolean? = true): String {
return when (data) {
is ByteArray -> encryptBase64(data, getKeyType(usePublicKey))
is String -> encryptBase64(data, getKeyType(usePublicKey))
is InputStream -> encryptBase64(data, getKeyType(usePublicKey))
else -> throw IllegalArgumentException("Unexpected input type")
}
return EncoderUtils.base64Encode(encrypt(data, usePublicKey))
}
}