diff options
| -rw-r--r-- | 04.md | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -23,12 +23,12 @@ import crypto from 'crypto' | |||
| 23 | import * as secp from 'noble-secp256k1' | 23 | import * as secp from 'noble-secp256k1' |
| 24 | 24 | ||
| 25 | let sharedPoint = secp.getSharedSecret(ourPrivateKey, '02' + theirPublicKey) | 25 | let sharedPoint = secp.getSharedSecret(ourPrivateKey, '02' + theirPublicKey) |
| 26 | let sharedX = sharedPoint.slice(2, 67) | 26 | let sharedX = sharedPoint.slice(1, 33) |
| 27 | 27 | ||
| 28 | let iv = crypto.randomFillSync(new Uint8Array(16)) | 28 | let iv = crypto.randomFillSync(new Uint8Array(16)) |
| 29 | var cipher = crypto.createCipheriv( | 29 | var cipher = crypto.createCipheriv( |
| 30 | 'aes-256-cbc', | 30 | 'aes-256-cbc', |
| 31 | Buffer.from(sharedX, 'hex'), | 31 | Buffer.from(sharedX), |
| 32 | iv | 32 | iv |
| 33 | ) | 33 | ) |
| 34 | let encryptedMessage = cipher.update(text, 'utf8', 'base64') | 34 | let encryptedMessage = cipher.update(text, 'utf8', 'base64') |