mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 17:25:52 +08:00
hotfix for cf deploy error #5168
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
import { createHash, createHmac } from "node:crypto";
|
||||
import hash from "hash.js";
|
||||
|
||||
// 使用 SHA-256 和 secret 进行 HMAC 加密
|
||||
function sha256(message: any, secret = "", encoding?: string) {
|
||||
return createHmac("sha256", secret)
|
||||
return hash
|
||||
.hmac(hash.sha256 as any, secret)
|
||||
.update(message)
|
||||
.digest(encoding as any);
|
||||
}
|
||||
|
||||
// 使用 SHA-256 进行哈希
|
||||
function getHash(message: any, encoding = "hex") {
|
||||
return createHash("sha256")
|
||||
return hash
|
||||
.sha256()
|
||||
.update(message)
|
||||
.digest(encoding as any);
|
||||
}
|
||||
|
Reference in New Issue
Block a user