From 4e94e0e279f893dad852d79775099e65c03a31ff Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 23 Oct 2019 14:32:42 +0800 Subject: [PATCH] up --- .../java/io/legado/app/help/JsExtensions.kt | 4 ++++ .../app/model/analyzeRule/AnalyzeRule.kt | 20 +++++++++++-------- .../java/io/legado/app/utils/EncoderUtils.kt | 4 ++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 1db26a4fe..4e9bf6c41 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -29,6 +29,10 @@ object JsExtensions { return EncoderUtils.base64Decoder(str) } + fun base64Encoder(str: String): ByteArray? { + return EncoderUtils.base64Encoder(str) + } + fun strToMd5By32(str: String?): String? { return MD5Utils.strToMd5By32(str) } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index cba7bc0f1..287774a77 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -576,6 +576,18 @@ class AnalyzeRule(private var book: BaseBook? = null) { return EncoderUtils.base64Decoder(str) } + fun base64Encoder(str: String): ByteArray? { + return EncoderUtils.base64Encoder(str) + } + + fun strToMd5By32(str: String?): String? { + return MD5Utils.strToMd5By32(str) + } + + fun strToMd5By16(str: String?): String? { + return MD5Utils.strToMd5By16(str) + } + /** * 章节数转数字 */ @@ -592,14 +604,6 @@ class AnalyzeRule(private var book: BaseBook? = null) { } } - fun strToMd5By32(str: String?): String? { - return MD5Utils.strToMd5By32(str) - } - - fun strToMd5By16(str: String?): String? { - return MD5Utils.strToMd5By16(str) - } - companion object { private val putPattern = Pattern.compile("@put:(\\{[^}]+?\\})", Pattern.CASE_INSENSITIVE) private val getPattern = Pattern.compile("@get:\\{([^}]+?)\\}", Pattern.CASE_INSENSITIVE) diff --git a/app/src/main/java/io/legado/app/utils/EncoderUtils.kt b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt index 112ac65f9..3798bfa9c 100644 --- a/app/src/main/java/io/legado/app/utils/EncoderUtils.kt +++ b/app/src/main/java/io/legado/app/utils/EncoderUtils.kt @@ -32,4 +32,8 @@ object EncoderUtils { String(bytes) } } + + fun base64Encoder(str: String): ByteArray? { + return Base64.encode(str.toByteArray(), Base64.DEFAULT) + } } \ No newline at end of file