优化
This commit is contained in:
@@ -2,6 +2,7 @@ package io.legado.app.help.crypto
|
|||||||
|
|
||||||
import cn.hutool.crypto.KeyUtil
|
import cn.hutool.crypto.KeyUtil
|
||||||
import cn.hutool.crypto.asymmetric.KeyType
|
import cn.hutool.crypto.asymmetric.KeyType
|
||||||
|
import io.legado.app.utils.EncoderUtils
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import cn.hutool.crypto.asymmetric.AsymmetricCrypto as HutoolAsymmetricCrypto
|
import cn.hutool.crypto.asymmetric.AsymmetricCrypto as HutoolAsymmetricCrypto
|
||||||
|
|
||||||
@@ -77,12 +78,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
|
|||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun encryptBase64(data: Any, usePublicKey: Boolean? = true): String {
|
fun encryptBase64(data: Any, usePublicKey: Boolean? = true): String {
|
||||||
return when (data) {
|
return EncoderUtils.base64Encode(encrypt(data, usePublicKey))
|
||||||
is ByteArray -> encryptBase64(data, getKeyType(usePublicKey))
|
|
||||||
is String -> encryptBase64(data, getKeyType(usePublicKey))
|
|
||||||
is InputStream -> encryptBase64(data, getKeyType(usePublicKey))
|
|
||||||
else -> throw IllegalArgumentException("Unexpected input type")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user