MCPcopy
hub / github.com/simstudioai/sim / encryptForTest

Function encryptForTest

packages/db/scripts/backfill-api-key-hash.test.ts:16–24  ·  view source on GitHub ↗
(plainKey: string, keyHex: string)

Source from the content-addressed store, hash-verified

14const FIXED_ENCRYPTION_KEY = '0'.repeat(64)
15
16function encryptForTest(plainKey: string, keyHex: string): string {
17 const key = Buffer.from(keyHex, 'hex')
18 const iv = Buffer.from('11'.repeat(16), 'hex')
19 const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
20 let encrypted = cipher.update(plainKey, 'utf8', 'hex')
21 encrypted += cipher.final('hex')
22 const authTag = cipher.getAuthTag()
23 return `${iv.toString('hex')}:${encrypted}:${authTag.toString('hex')}`
24}
25
26describe('hashApiKey', () => {
27 it('is deterministic', () => {

Callers 1

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected