优化
This commit is contained in:
@@ -32,7 +32,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
|
|||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun decrypt(data: Any, usePublicKey: Boolean? = true): ByteArray {
|
fun decrypt(data: Any, usePublicKey: Boolean? = true): ByteArray {
|
||||||
return {
|
return when {
|
||||||
data is ByteArray -> decrypt(data, getKeyType(usePublicKey))
|
data is ByteArray -> decrypt(data, getKeyType(usePublicKey))
|
||||||
data is String -> decrypt(data, getKeyType(usePublicKey))
|
data is String -> decrypt(data, getKeyType(usePublicKey))
|
||||||
data is InputStream -> decrypt(data, getKeyType(usePublicKey))
|
data is InputStream -> decrypt(data, getKeyType(usePublicKey))
|
||||||
@@ -42,7 +42,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
|
|||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun decryptStr(data: Any, usePublicKey: Boolean? = true): String {
|
fun decryptStr(data: Any, usePublicKey: Boolean? = true): String {
|
||||||
return {
|
return when {
|
||||||
data is ByteArray -> decryptStr(data, getKeyType(usePublicKey))
|
data is ByteArray -> decryptStr(data, getKeyType(usePublicKey))
|
||||||
data is String -> decryptStr(data, getKeyType(usePublicKey))
|
data is String -> decryptStr(data, getKeyType(usePublicKey))
|
||||||
data is InputStream -> decryptStr(data, getKeyType(usePublicKey))
|
data is InputStream -> decryptStr(data, getKeyType(usePublicKey))
|
||||||
@@ -52,7 +52,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
|
|||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun encrypt(data: Any, usePublicKey: Boolean? = true): ByteArray {
|
fun encrypt(data: Any, usePublicKey: Boolean? = true): ByteArray {
|
||||||
return {
|
return when {
|
||||||
data is ByteArray -> encrypt(data, getKeyType(usePublicKey))
|
data is ByteArray -> encrypt(data, getKeyType(usePublicKey))
|
||||||
data is String -> encrypt(data, getKeyType(usePublicKey))
|
data is String -> encrypt(data, getKeyType(usePublicKey))
|
||||||
data is InputStream -> encrypt(data, getKeyType(usePublicKey))
|
data is InputStream -> encrypt(data, getKeyType(usePublicKey))
|
||||||
@@ -62,7 +62,7 @@ class AsymmetricCrypto(algorithm: String) : HutoolAsymmetricCrypto(algorithm) {
|
|||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun encryptHex(data: Any, usePublicKey: Boolean? = true): String {
|
fun encryptHex(data: Any, usePublicKey: Boolean? = true): String {
|
||||||
return {
|
return when {
|
||||||
data is ByteArray -> encryptHex(data, getKeyType(usePublicKey))
|
data is ByteArray -> encryptHex(data, getKeyType(usePublicKey))
|
||||||
data is String -> encryptHex(data, getKeyType(usePublicKey))
|
data is String -> encryptHex(data, getKeyType(usePublicKey))
|
||||||
data is InputStream -> encryptHex(data, getKeyType(usePublicKey))
|
data is InputStream -> encryptHex(data, getKeyType(usePublicKey))
|
||||||
@@ -72,7 +72,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 {
|
return when {
|
||||||
data is ByteArray -> encryptBase64(data, getKeyType(usePublicKey))
|
data is ByteArray -> encryptBase64(data, getKeyType(usePublicKey))
|
||||||
data is String -> encryptBase64(data, getKeyType(usePublicKey))
|
data is String -> encryptBase64(data, getKeyType(usePublicKey))
|
||||||
data is InputStream -> encryptBase64(data, getKeyType(usePublicKey))
|
data is InputStream -> encryptBase64(data, getKeyType(usePublicKey))
|
||||||
|
|||||||
Reference in New Issue
Block a user