优化
This commit is contained in:
@@ -219,7 +219,7 @@ java.createAsymmetricCrypto(transformation)
|
||||
//解密为ByteArray String
|
||||
cipher.decrypt(data, usePublicKey: Boolean? = true
|
||||
)
|
||||
cipher.decryptStr(data, usePublicKey: Boolean? = true
|
||||
cipher.decryptStr(data: String!!, usePublicKey: Boolean? = true
|
||||
)
|
||||
//加密为ByteArray Base64字符 HEX字符
|
||||
cipher.encrypt(data, usePublicKey: Boolean? = true
|
||||
|
||||
@@ -41,11 +41,9 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun decryptStr(data: Any, usePublicKey: Boolean? = true): String {
|
||||
fun decryptStr(data: String, usePublicKey: Boolean? = true): String {
|
||||
return when {
|
||||
data is ByteArray -> decryptStr(data, getKeyType(usePublicKey))
|
||||
data is String -> decryptStr(data, getKeyType(usePublicKey))
|
||||
data is InputStream -> decryptStr(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: Any, usePublicKey: Boolean? = true): String?
|
||||
fun decryptStr(data: String, usePublicKey: Boolean? = true): String?
|
||||
|
||||
fun encrypt(data: Any, usePublicKey: Boolean? = true): ByteArray?
|
||||
fun encryptHex(data: Any, usePublicKey: Boolean? = true): String?
|
||||
|
||||
Reference in New Issue
Block a user