优化
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user