diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt index 284bc82c5..99e92a942 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt @@ -22,14 +22,15 @@ actual fun crc32(key: ByteArray): Int = CRC32().let { it.update(key); it.value.t actual fun md5(byteArray: ByteArray): ByteArray = MessageDigest.getInstance("MD5").digest(byteArray) fun InputStream.md5(): ByteArray = this.use { - val digest = MessageDigest.getInstance("md5") digest.reset() - this.transferTo(object : OutputStream() { - override fun write(b: Int) { - digest.update(b.toByte()) - } - }) + this.use { + it.copyTo(object : OutputStream() { + override fun write(b: Int) { + digest.update(b.toByte()) + } + }) + } return digest.digest() }