mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-06 08:00:10 +08:00
Use kotlin rather that JDK9
This commit is contained in:
parent
6a605156e5
commit
4e57eea779
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user