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