mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
feat: add some decryption methods
This commit is contained in:
parent
878a4a211f
commit
bcc2c5b219
@ -219,6 +219,9 @@ dependencies {
|
||||
//转换繁体
|
||||
implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.3')
|
||||
|
||||
//加解密类库
|
||||
implementation('cn.hutool:hutool-crypto:5.7.19')
|
||||
|
||||
//代码编辑com.github.AmrDeveloper:CodeView已集成到应用内
|
||||
//epubLib集成到应用内
|
||||
|
||||
|
@ -3,6 +3,8 @@ package io.legado.app.help
|
||||
import android.net.Uri
|
||||
import android.util.Base64
|
||||
import androidx.annotation.Keep
|
||||
import cn.hutool.crypto.symmetric.AES
|
||||
import cn.hutool.crypto.symmetric.DESede
|
||||
import io.legado.app.BuildConfig
|
||||
import io.legado.app.constant.AppConst
|
||||
import io.legado.app.constant.AppConst.dateFormat
|
||||
@ -688,4 +690,74 @@ interface JsExtensions {
|
||||
return AppConst.androidId
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密,算法参数经过Base64加密
|
||||
*
|
||||
* @param data 加密的字符串
|
||||
* @param key Base64后的密钥
|
||||
* @param mode 模式
|
||||
* @param padding 补码方式
|
||||
* @param iv Base64后的加盐
|
||||
* @return 解密后的字符串
|
||||
*/
|
||||
fun aesDecodeArgsBase64Str(
|
||||
data: String,
|
||||
key: String,
|
||||
mode: String,
|
||||
padding: String,
|
||||
iv: String
|
||||
): String? {
|
||||
return AES(
|
||||
mode,
|
||||
padding,
|
||||
Base64.decode(key, Base64.NO_WRAP),
|
||||
Base64.decode(iv, Base64.NO_WRAP)
|
||||
).decryptStr(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 3DES解密
|
||||
*
|
||||
* @param data 加密的字符串
|
||||
* @param key 密钥
|
||||
* @param mode 模式
|
||||
* @param padding 补码方式
|
||||
* @param iv 加盐
|
||||
* @return 解密后的字符串
|
||||
*/
|
||||
fun tripleDESDecodeStr(
|
||||
data: String,
|
||||
key: String,
|
||||
mode: String,
|
||||
padding: String,
|
||||
iv: String
|
||||
): String? {
|
||||
return DESede(mode, padding, key.toByteArray(), iv.toByteArray()).decryptStr(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 3DES解密,算法参数经过Base64加密
|
||||
*
|
||||
* @param data 加密的字符串
|
||||
* @param key Base64后的密钥
|
||||
* @param mode 模式
|
||||
* @param padding 补码方式
|
||||
* @param iv Base64后的加盐
|
||||
* @return 解密后的字符串
|
||||
*/
|
||||
fun tripleDESDecodeArgsBase64Str(
|
||||
data: String,
|
||||
key: String,
|
||||
mode: String,
|
||||
padding: String,
|
||||
iv: String
|
||||
): String? {
|
||||
return DESede(
|
||||
mode,
|
||||
padding,
|
||||
Base64.decode(key, Base64.NO_WRAP),
|
||||
Base64.decode(iv, Base64.NO_WRAP)
|
||||
).decryptStr(data)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user