MCPcopy Index your code
hub / github.com/simstudioai/sim / encryptSecret

Function encryptSecret

packages/db/scripts/migrate-block-api-keys-to-byok.ts:126–134  ·  view source on GitHub ↗
(secret: string)

Source from the content-addressed store, hash-verified

124}
125
126async function encryptSecret(secret: string): Promise<string> {
127 const iv = randomBytes(16)
128 const key = getEncryptionKeyBuffer()
129 const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
130 let encrypted = cipher.update(secret, 'utf8', 'hex')
131 encrypted += cipher.final('hex')
132 const authTag = cipher.getAuthTag()
133 return `${iv.toString('hex')}:${encrypted}:${authTag.toString('hex')}`
134}
135
136async function decryptSecret(encryptedValue: string): Promise<string> {
137 const parts = encryptedValue.split(':')

Callers 1

processWorkspaceFunction · 0.70

Calls 2

getEncryptionKeyBufferFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected