(data: any, secret: Uint8Array)
| 70 | * Encrypt data using NaCl secretbox (legacy) |
| 71 | */ |
| 72 | export function encryptLegacy(data: any, secret: Uint8Array): Uint8Array { |
| 73 | const nonce = getRandomBytes(tweetnacl.secretbox.nonceLength); |
| 74 | const encrypted = tweetnacl.secretbox(new TextEncoder().encode(JSON.stringify(data)), nonce, secret); |
| 75 | const result = new Uint8Array(nonce.length + encrypted.length); |
| 76 | result.set(nonce); |
| 77 | result.set(encrypted, nonce.length); |
| 78 | return result; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Decrypt data using NaCl secretbox (legacy) |
no test coverage detected