MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / encryptToken

Function encryptToken

packages/server/src/enterprise/utils/tempTokenUtils.ts:31–43  ·  view source on GitHub ↗
(stringToEncrypt: string)

Source from the content-addressed store, hash-verified

29
30// Encrypt token with password using crypto.Cipheriv
31export const encryptToken = (stringToEncrypt: string) => {
32 const key = crypto.createHash('sha256').update(getTokenHashSecret()).digest()
33
34 const IV_LENGTH = 16
35 const iv = crypto.randomBytes(IV_LENGTH)
36 const cipher = crypto.createCipheriv('aes-256-cbc', key, iv)
37 const encrypted = cipher.update(stringToEncrypt)
38
39 const result = Buffer.concat([encrypted, cipher.final()])
40
41 // formatted string [iv]:[token]
42 return iv.toString('hex') + ':' + result.toString('hex')
43}
44
45// Decrypt token using the inverse of encryption crypto algorithm
46export const decryptToken = (stringToDecrypt: string): string | undefined => {

Callers 1

_generateJwtTokenFunction · 0.90

Calls 2

getTokenHashSecretFunction · 0.90
updateMethod · 0.65

Tested by

no test coverage detected