mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
feat: add digest encryption method
This commit is contained in:
parent
bcc2c5b219
commit
b4ffa4d128
@ -3,6 +3,7 @@ package io.legado.app.help
|
||||
import android.net.Uri
|
||||
import android.util.Base64
|
||||
import androidx.annotation.Keep
|
||||
import cn.hutool.crypto.digest.DigestUtil
|
||||
import cn.hutool.crypto.symmetric.AES
|
||||
import cn.hutool.crypto.symmetric.DESede
|
||||
import io.legado.app.BuildConfig
|
||||
@ -760,4 +761,32 @@ interface JsExtensions {
|
||||
).decryptStr(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成摘要,并转为16进制字符串
|
||||
*
|
||||
* @param data 被摘要数据
|
||||
* @param algorithm 签名算法
|
||||
* @return 16进制字符串
|
||||
*/
|
||||
fun digestHex(
|
||||
data: String,
|
||||
algorithm: String,
|
||||
): String? {
|
||||
return DigestUtil.digester(algorithm).digestHex(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成摘要,并转为Base64字符串
|
||||
*
|
||||
* @param data 被摘要数据
|
||||
* @param algorithm 签名算法
|
||||
* @return Base64字符串
|
||||
*/
|
||||
fun digestBase64Str(
|
||||
data: String,
|
||||
algorithm: String,
|
||||
): String? {
|
||||
return Base64.encodeToString(DigestUtil.digester(algorithm).digest(data), Base64.NO_WRAP)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user