Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

634 B
Raw Blame
import { createHash, randomBytes } from 'node:crypto'
import { promisify } from 'node:util'

const randomBytesPromisified = promisify(randomBytes)

export const cryptoUtils = {
    async generateRandomPassword(): Promise<string> {
        const passwordBytes = await randomBytesPromisified(32)
        return passwordBytes.toString('hex')
    },
    hashSHA256(input: string): string {
        const hash = createHash('sha256')
        hash.update(input)
        return hash.digest('hex')
    },
    async hashObject(obj: Record<string, unknown>): Promise<string> {
        return cryptoUtils.hashSHA256(JSON.stringify(obj))
    },
}