mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
b8ac7e2476
commit
2fbca2b655
@ -1,7 +1,9 @@
|
|||||||
package io.legado.app.utils
|
package io.legado.app.utils
|
||||||
|
|
||||||
import cn.hutool.crypto.digest.DigestUtil
|
import cn.hutool.crypto.digest.DigestUtil
|
||||||
|
import cn.hutool.crypto.digest.Digester
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
import kotlin.concurrent.getOrSet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将字符串转化为MD5
|
* 将字符串转化为MD5
|
||||||
@ -9,12 +11,19 @@ import java.io.InputStream
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
object MD5Utils {
|
object MD5Utils {
|
||||||
|
|
||||||
|
private val threadLocal = ThreadLocal<Digester>()
|
||||||
|
|
||||||
|
private val MD5Digester
|
||||||
|
get() = threadLocal.getOrSet {
|
||||||
|
DigestUtil.digester("MD5")
|
||||||
|
}
|
||||||
|
|
||||||
fun md5Encode(str: String?): String {
|
fun md5Encode(str: String?): String {
|
||||||
return DigestUtil.digester("MD5").digestHex(str)
|
return MD5Digester.digestHex(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun md5Encode(inputStream: InputStream): String {
|
fun md5Encode(inputStream: InputStream): String {
|
||||||
return DigestUtil.digester("MD5").digestHex(inputStream)
|
return MD5Digester.digestHex(inputStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun md5Encode16(str: String): String {
|
fun md5Encode16(str: String): String {
|
||||||
|
Loading…
Reference in New Issue
Block a user