api/crypto: use buffers for salt directly instead of hex strings

This commit is contained in:
jj 2024-10-31 22:42:46 +00:00
parent 93e6344fc7
commit 2d6d406f48
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import { createHmac, createCipheriv, createDecipheriv, randomBytes } from "crypt
const algorithm = "aes256";
export function generateSalt() {
return randomBytes(64).toString('hex');
return randomBytes(64);
}
export function generateHmac(str, salt) {

View file

@ -7,7 +7,7 @@ import { setMaxListeners } from "node:events";
import { env, tunnelPort } from "../config.js";
import { closeRequest } from "./shared.js";
import { decryptStream, encryptStream, generateHmac } from "../misc/crypto.js";
import { decryptStream, encryptStream, generateHmac, generateSalt } from "../misc/crypto.js";
// optional dependency
const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
@ -15,7 +15,7 @@ const freebind = env.freebindCIDR && await import('freebind').catch(() => {});
const streamCache = new Store('streams');
const internalStreamCache = new Map();
const hmacSalt = randomBytes(64).toString('hex');
const hmacSalt = generateSalt();
export function createStream(obj) {
const streamID = nanoid(),