From 40f9b887f40b61c4d4f87d92681412fe486ba959 Mon Sep 17 00:00:00 2001 From: Emil Bay Date: Wed, 24 Jun 2020 14:49:26 +0200 Subject: [PATCH] Modernise example --- example.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/example.js b/example.js index b3c8b29..7cc63f7 100644 --- a/example.js +++ b/example.js @@ -1,19 +1,19 @@ -var sodium = require('./') +const sodium = require('./') -var key = Buffer.alloc(sodium.crypto_secretbox_KEYBYTES) -var nonce = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES) +const key = Buffer.alloc(sodium.crypto_secretbox_KEYBYTES) +const nonce = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES) sodium.randombytes_buf(key) sodium.randombytes_buf(nonce) -var message = Buffer.from('Hello, World!') -var cipher = Buffer.alloc(message.length + sodium.crypto_secretbox_MACBYTES) +const message = Buffer.from('Hello, World!') +const cipher = Buffer.alloc(message.length + sodium.crypto_secretbox_MACBYTES) sodium.crypto_secretbox_easy(cipher, message, nonce, key) console.log('Encrypted:', cipher) -var plainText = Buffer.alloc(cipher.length - sodium.crypto_secretbox_MACBYTES) +const plainText = Buffer.alloc(cipher.length - sodium.crypto_secretbox_MACBYTES) sodium.crypto_secretbox_open_easy(plainText, cipher, nonce, key)