From 3aa51ecb6f20e6120a56beecce020a1a0293af95 Mon Sep 17 00:00:00 2001 From: michael6 Date: Thu, 1 Dec 2016 11:18:33 -0600 Subject: [PATCH] test: refactor test-crypto-ecb * var -> const/let * IIFE to blocks PR-URL: https://github.com/nodejs/node/pull/10029 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- test/parallel/test-crypto-ecb.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-crypto-ecb.js b/test/parallel/test-crypto-ecb.js index d423a386b30a19..655246d0586cbf 100644 --- a/test/parallel/test-crypto-ecb.js +++ b/test/parallel/test-crypto-ecb.js @@ -1,6 +1,6 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); @@ -10,24 +10,25 @@ if (common.hasFipsCrypto) { common.skip('BF-ECB is not FIPS 140-2 compatible'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); crypto.DEFAULT_ENCODING = 'buffer'; // Testing whether EVP_CipherInit_ex is functioning correctly. // Reference: bug#1997 -(function() { - var encrypt = crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', ''); - var hex = encrypt.update('Hello World!', 'ascii', 'hex'); +{ + const encrypt = + crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', ''); + let hex = encrypt.update('Hello World!', 'ascii', 'hex'); hex += encrypt.final('hex'); assert.strictEqual(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71'); -}()); +} -(function() { - var decrypt = crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', - ''); - var msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii'); +{ + const decrypt = + crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', ''); + let msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii'); msg += decrypt.final('ascii'); assert.strictEqual(msg, 'Hello World!'); -}()); +}