From cdd4dc169b499141f24bee968e48d2a764e4af8b Mon Sep 17 00:00:00 2001 From: tursom Date: Thu, 24 Oct 2019 22:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20token=20=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=20TokenUtil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/src/main/kotlin/cn/tursom/utils/TokenUtil.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/utils/src/main/kotlin/cn/tursom/utils/TokenUtil.kt b/utils/src/main/kotlin/cn/tursom/utils/TokenUtil.kt index e737e2f..ca15e86 100644 --- a/utils/src/main/kotlin/cn/tursom/utils/TokenUtil.kt +++ b/utils/src/main/kotlin/cn/tursom/utils/TokenUtil.kt @@ -20,11 +20,7 @@ open class TokenUtil { val head = type.digestBase64 val body = toJson(TokenBody(System.currentTimeMillis(), timeout, data)).base64() val encryptSource = "$head.$body".toByteArray() - val encryptKey = secretKey.toByteArray() - encryptSource.forEachIndexed { index, _ -> - encryptSource[index] = encryptSource[index] xor encryptKey[index % encryptKey.size] - } - val encrypt = encryptSource.digest(type.digest)!!.toHexString() + val encrypt = encrypt(secretKey, encryptSource, type.digest) return "$head.$body.$encrypt" } @@ -74,4 +70,3 @@ open class TokenUtil { val instance = TokenUtil() } } -