From 1728e80532decfcd92f4e9f6efa4250463c2527b Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 7 Oct 2019 18:13:52 +0800 Subject: [PATCH] Add ByteArray.decryptBy --- mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/Utils.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/Utils.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/Utils.kt index ddfc61010..4a45533c9 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/Utils.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/Utils.kt @@ -84,6 +84,11 @@ fun dataDecode(byteArray: ByteArray, t: (DataInputStream) -> R): R = byteArr fun ByteArray.decode(t: (DataInputStream) -> R): R = this.dataInputStream().let(t) +fun ByteArray.decryptBy(key: ByteArray): ByteArray = TEA.decrypt(this, key) + +fun ByteArray.decryptBy(key: String): ByteArray = TEA.decrypt(this, key) + + fun DataInputStream.skip(n: Number) { this.skip(n.toLong()) }