This commit is contained in:
Xwite
2023-03-15 11:03:37 +08:00
parent 5c65b8eaad
commit 2b4785a0f5
3 changed files with 5 additions and 3 deletions
@@ -41,9 +41,11 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
}
@JvmOverloads
fun decryptStr(data: String, usePublicKey: Boolean? = true): String {
fun decryptStr(data: Any, usePublicKey: Boolean? = true): String {
return when {
data is ByteArray -> String(decrypt(data, getKeyType(usePublicKey)))
data is String -> decryptStr(data, getKeyType(usePublicKey))
data is InputStream -> String(decrypt(data, getKeyType(usePublicKey)))
else -> throw IllegalArgumentException("Unexpected input type")
}
}
@@ -8,7 +8,7 @@ fun setPrivateKey(key: ByteArray): T
fun setPrivateKey(key: String): T
fun decrypt(data: Any, usePublicKey: Boolean? = true): ByteArray?
fun decryptStr(data: String, usePublicKey: Boolean? = true): String?
fun decryptStr(data: Any, usePublicKey: Boolean? = true): String?
fun encrypt(data: Any, usePublicKey: Boolean? = true): ByteArray?
fun encryptHex(data: Any, usePublicKey: Boolean? = true): String?