pull/2306/head
Horis 2 years ago
parent 91188f1b06
commit 27f0c9e0f1
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  2. 6
      app/src/main/java/io/legado/app/utils/MD5Utils.kt

@ -353,7 +353,11 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
private fun setBgFromUri(uri: Uri) {
readUri(uri) { fileDoc, inputStream ->
var file = requireContext().externalFiles
file = FileUtils.createFileIfNotExist(file, "bg", fileDoc.name)
val suffix = fileDoc.name.substringAfterLast(".")
val fileName = uri.inputStream(requireContext())!!.use {
MD5Utils.md5Encode(it) + ".$suffix"
}
file = FileUtils.createFileIfNotExist(file, "bg", fileName)
FileOutputStream(file).use { outputStream ->
inputStream.copyTo(outputStream)
}

@ -1,6 +1,8 @@
package io.legado.app.utils
import cn.hutool.crypto.digest.DigestUtil
import java.io.InputStream
/**
* 将字符串转化为MD5
*/
@ -11,6 +13,10 @@ object MD5Utils {
return DigestUtil.digester("MD5").digestHex(str)
}
fun md5Encode(inputStream: InputStream): String {
return DigestUtil.digester("MD5").digestHex(inputStream)
}
fun md5Encode16(str: String): String {
var reStr = md5Encode(str)
reStr = reStr.substring(8, 24)

Loading…
Cancel
Save