mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -159,6 +159,11 @@ java.hexDecodeToString(hex: String)
|
||||
utf8 编码为hexString
|
||||
java.hexEncodeToString(utf8: String)
|
||||
```
|
||||
* 标识id
|
||||
```
|
||||
java.randomUUID()
|
||||
java.androidId()
|
||||
```
|
||||
* 文件
|
||||
> 所有对于文件的读写删操作都是相对路径,只能操作阅读缓存/android/data/{package}/cache/内的文件
|
||||
```
|
||||
@@ -206,11 +211,10 @@ cipher.encryptBase64(data)
|
||||
cipher.encryptHex(data)
|
||||
```
|
||||
* 非对称加密 RSA/ECIES(不支持)
|
||||
> algorithm: RSA, RSA/ECB/PKCS1Padding, RSA/ECB/NoPadding, RSA/None/NoPadding, RSA/None/NoPadding
|
||||
> 输入参数密钥 支持ByteArray|**Utf8String**
|
||||
```
|
||||
//创建cipher
|
||||
java.createAsymmetricCrypto(algorithm, privateKey, publicKey)
|
||||
java.createAsymmetricCrypto(transformation, privateKey, publicKey)
|
||||
```
|
||||
> 解密加密参数 data支持ByteArray|Base64String|HexString|InputStream
|
||||
> keyType: 1 使用公钥 2 使用私钥
|
||||
|
||||
@@ -71,20 +71,20 @@ interface JsEncodeUtils {
|
||||
|
||||
/* keys都为null时使用随机密钥 */
|
||||
fun createAsymmetricCrypto(
|
||||
algorithm: String,
|
||||
transformation: String,
|
||||
privateKey: ByteArray?,
|
||||
publicKey: ByteArray?
|
||||
): AsymmetricCrypto {
|
||||
return AsymmetricCrypto(algorithm, privateKey, publicKey)
|
||||
return AsymmetricCrypto(transformation, privateKey, publicKey)
|
||||
}
|
||||
|
||||
fun createAsymmetricCrypto(
|
||||
algorithm: String,
|
||||
transformation: String,
|
||||
privateKey: String?,
|
||||
publicKey: String?
|
||||
): AsymmetricCrypto {
|
||||
return createAsymmetricCrypto(
|
||||
algorithm,
|
||||
transformation,
|
||||
privateKey?.encodeToByteArray(),
|
||||
publicKey?.encodeToByteArray()
|
||||
)
|
||||
|
||||
@@ -523,8 +523,9 @@ interface JsExtensions : JsEncodeUtils {
|
||||
fun unArchiveFile(zipPath: String): String {
|
||||
if (zipPath.isEmpty()) return ""
|
||||
val zipFile = getFile(zipPath)
|
||||
return ArchiveUtils.deCompress(zipFile.absolutePath).toString()
|
||||
.substring(FileUtils.getCachePath().length)
|
||||
return ArchiveUtils.deCompress(zipFile.absolutePath).let {
|
||||
ArchiveUtils.TEMP_FOLDER_NAME + File.separator + MD5Utils.md5Encode16(zipFile.name)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -540,7 +540,7 @@ class BookInfoActivity :
|
||||
onClick?.invoke(it)
|
||||
}
|
||||
} else {
|
||||
showDecompressFileImportAlert(files)
|
||||
showDecompressFileImportAlert(files, onClick)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,10 @@ import java.io.File
|
||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
object ArchiveUtils {
|
||||
|
||||
const val TEMP_FOLDER_NAME = "ArchiveTemp"
|
||||
// 临时目录 下次启动自动删除
|
||||
val TEMP_PATH: String by lazy {
|
||||
appCtx.externalCache.getFile("ArchiveTemp").createFolderReplace().absolutePath
|
||||
appCtx.externalCache.getFile(TEMP_FOLDER_NAME).createFolderReplace().absolutePath
|
||||
}
|
||||
|
||||
fun deCompress(
|
||||
|
||||
Reference in New Issue
Block a user