(plainKey: string, keyHex: string)
| 14 | const FIXED_ENCRYPTION_KEY = '0'.repeat(64) |
| 15 | |
| 16 | function 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 | |
| 26 | describe('hashApiKey', () => { |
| 27 | it('is deterministic', () => { |
no test coverage detected