@sentzunhat/zacatl
Version:
A modular, high-performance TypeScript microservice framework for Node.js, featuring layered architecture, dependency injection, and robust validation for building scalable APIs and distributed systems.
14 lines (12 loc) • 422 B
text/typescript
import { createHmac } from "crypto";
/**
* Function to generate HMAC using a secret key
* @param message - The message to be hashed
* @param secretKey - The secret key used for HMAC
* @returns The HMAC digest in hexadecimal format
*/
export const generateHmac = (message: string, secretKey: string): string => {
const hmac = createHmac("sha256", secretKey);
hmac.update(message);
return hmac.digest("hex");
};