mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
pref: 安全特性支持,站点隐藏功能
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import crypto, { BinaryToTextEncoding } from 'crypto';
|
||||
import crypto, { BinaryToTextEncoding } from "crypto";
|
||||
|
||||
function md5(data: string, digest: BinaryToTextEncoding = 'hex') {
|
||||
return crypto.createHash('md5').update(data).digest(digest);
|
||||
function md5(data: string, digest: BinaryToTextEncoding = "hex") {
|
||||
return crypto.createHash("md5").update(data).digest(digest);
|
||||
}
|
||||
function sha256(data: string, digest: BinaryToTextEncoding = 'hex') {
|
||||
return crypto.createHash('sha256').update(data).digest(digest);
|
||||
function sha256(data: string, digest: BinaryToTextEncoding = "hex") {
|
||||
return crypto.createHash("sha256").update(data).digest(digest);
|
||||
}
|
||||
|
||||
function hmacSha256(data: string, digest: BinaryToTextEncoding = 'base64') {
|
||||
return crypto.createHmac('sha256', data).update(Buffer.alloc(0)).digest(digest);
|
||||
function hmacSha256(data: string, digest: BinaryToTextEncoding = "base64") {
|
||||
return crypto.createHmac("sha256", data).update(Buffer.alloc(0)).digest(digest);
|
||||
}
|
||||
|
||||
function base64(data: string) {
|
||||
return Buffer.from(data).toString('base64');
|
||||
return Buffer.from(data).toString("base64");
|
||||
}
|
||||
export const hashUtils = {
|
||||
md5,
|
||||
|
||||
Reference in New Issue
Block a user