Best JavaScript code snippet using wpt
des.js
Source:des.js
...6 describe('des', function() {7 // OpenSSL equivalent:8 // openssl enc -des-ecb -K a1c06b381adf3651 -nosalt9 it('should des-ecb encrypt: foobar', function() {10 var key = new UTIL.createBuffer(11 UTIL.hexToBytes('a1c06b381adf3651'));12 var cipher = CIPHER.createCipher('DES-ECB', key);13 cipher.start();14 cipher.update(UTIL.createBuffer('foobar'));15 cipher.finish();16 ASSERT.equal(cipher.output.toHex(), 'b705ffcf3dff06b3');17 });18 // OpenSSL equivalent:19 // openssl enc -d -des-ecb -K a1c06b381adf3651 -nosalt20 it('should des-ecb decrypt: b705ffcf3dff06b3', function() {21 var key = new UTIL.createBuffer(22 UTIL.hexToBytes('a1c06b381adf3651'));23 var decipher = CIPHER.createDecipher('DES-ECB', key);24 decipher.start();25 decipher.update(UTIL.createBuffer(UTIL.hexToBytes('b705ffcf3dff06b3')));26 decipher.finish();27 ASSERT.equal(decipher.output.getBytes(), 'foobar');28 });29 it('should check des-cbc short IV', function() {30 var key = new UTIL.createBuffer(31 UTIL.hexToBytes('a1c06b381adf3651'));32 var iv = new UTIL.createBuffer(33 UTIL.hexToBytes('818bcf76efc596'));34 var error = null;35 try {36 var cipher = CIPHER.createCipher('DES-CBC', key);37 cipher.start({iv: iv});38 } catch(e) {39 error = e;40 }41 ASSERT.ok(error, 'blocksize check should have failed');42 });43 // OpenSSL equivalent:44 // openssl enc -des -K a1c06b381adf3651 -iv 818bcf76efc59662 -nosalt45 it('should des-cbc encrypt: foobar', function() {46 var key = new UTIL.createBuffer(47 UTIL.hexToBytes('a1c06b381adf3651'));48 var iv = new UTIL.createBuffer(49 UTIL.hexToBytes('818bcf76efc59662'));50 var cipher = CIPHER.createCipher('DES-CBC', key);51 cipher.start({iv: iv});52 cipher.update(UTIL.createBuffer('foobar'));53 cipher.finish();54 ASSERT.equal(cipher.output.toHex(), '3261e5839a990454');55 });56 // OpenSSL equivalent:57 // openssl enc -d -des -K a1c06b381adf3651 -iv 818bcf76efc59662 -nosalt58 it('should des-cbc decrypt: 3261e5839a990454', function() {59 var key = new UTIL.createBuffer(60 UTIL.hexToBytes('a1c06b381adf3651'));61 var iv = new UTIL.createBuffer(62 UTIL.hexToBytes('818bcf76efc59662'));63 var decipher = CIPHER.createDecipher('DES-CBC', key);64 decipher.start({iv: iv});65 decipher.update(UTIL.createBuffer(UTIL.hexToBytes('3261e5839a990454')));66 decipher.finish();67 ASSERT.equal(decipher.output.getBytes(), 'foobar');68 });69 // play.golang.org/p/LX_dP0cFuEt70 it('should des-ctr encrypt: foobar', function() {71 var key = new UTIL.createBuffer(72 UTIL.hexToBytes('a1c06b381adf3651'));73 var iv = new UTIL.createBuffer(74 UTIL.hexToBytes('818bcf76efc59662'));75 var cipher = CIPHER.createCipher('DES-CTR', key);76 cipher.start({iv: iv});77 cipher.update(UTIL.createBuffer('foobar'));78 cipher.finish();79 ASSERT.equal(cipher.output.toHex(), '3a97fa79e631');80 });81 // play.golang.org/p/6_MQBYzn04c82 it('should des-ctr decrypt: foobar', function() {83 var key = new UTIL.createBuffer(84 UTIL.hexToBytes('beefdeadbeefdead'));85 var iv = new UTIL.createBuffer(86 UTIL.hexToBytes('deadbeefdeadbeef'));87 var cipher = CIPHER.createDecipher('DES-CTR', key);88 cipher.start({iv: iv});89 cipher.update(UTIL.createBuffer(UTIL.hexToBytes('6df74b7b4437')));90 cipher.finish();91 ASSERT.equal(cipher.output.getBytes(), 'foobar');92 });93 // play.golang.org/p/i892aR7YsGK94 it('should des-ctr encrypt: dead parrot', function() {95 var key = new UTIL.createBuffer(96 UTIL.hexToBytes('a1c06b381adf3651'));97 var iv = new UTIL.createBuffer(98 UTIL.hexToBytes('818bcf76efc59662'));99 var cipher = CIPHER.createCipher('DES-CTR', key);100 cipher.start({iv: iv});101 cipher.update(UTIL.createBuffer('dead parrot'));102 cipher.finish();103 ASSERT.equal(cipher.output.toHex(), '389df47fa733dcf4b99b7c');104 });105 // play.golang.org/p/6L0LqPS9ARt106 it('should des-ctr decrypt: 79f1527c5737f774f85c1a9399755d895ae7', function() {107 var key = new UTIL.createBuffer(108 UTIL.hexToBytes('beefdeadbeefdead'));109 var iv = new UTIL.createBuffer(110 UTIL.hexToBytes('deadbeefdeadbeef'));111 var cipher = CIPHER.createDecipher('DES-CTR', key);112 cipher.start({iv: iv});113 cipher.update(UTIL.createBuffer(UTIL.hexToBytes('79f1527c5737f774f85c1a9399755d895ae7')));114 cipher.finish();115 ASSERT.equal(cipher.output.getBytes(), 'riverrun, past Eve');116 });117 // play.golang.org/p/WsSx6BXJniU118 it('should des-ctr encrypt: 69742773206e6f742073696c6c7920656e6f756768', function() {119 var key = new UTIL.createBuffer(120 UTIL.hexToBytes('a1c06b381adf3651'));121 var iv = new UTIL.createBuffer(122 UTIL.hexToBytes('818bcf76efc59662'));123 var cipher = CIPHER.createCipher('DES-CTR', key);124 cipher.start({iv: iv});125 cipher.update(UTIL.createBuffer(UTIL.hexToBytes('69742773206e6f742073696c6c7920656e6f756768')));126 cipher.finish();127 ASSERT.equal(cipher.output.toHex(), '358cb268a72dd2f2eb87615060bd3a490e85136873');128 });129 // play.golang.org/p/y01inAlMCEM130 it('should des-ctr decrypt: 0a80bd81a4dc1303a62f', function() {131 var key = new UTIL.createBuffer(132 UTIL.hexToBytes('beefdeadbeefdead'));133 var iv = new UTIL.createBuffer(134 UTIL.hexToBytes('deadbeefdeadbeef'));135 var cipher = CIPHER.createDecipher('DES-CTR', key);136 cipher.start({iv: iv});137 cipher.update(UTIL.createBuffer(UTIL.hexToBytes('0a80bd81a4dc1303a62f')));138 cipher.finish();139 ASSERT.equal(cipher.output.toHex(), '01189998819991197253');140 });141 // OpenSSL equivalent:142 // openssl enc -des-ede3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -nosalt143 it('should 3des-ecb encrypt: foobar', function() {144 var key = new UTIL.createBuffer(145 UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));146 var cipher = CIPHER.createCipher('3DES-ECB', key);147 cipher.start();148 cipher.update(UTIL.createBuffer('foobar'));149 cipher.finish();150 ASSERT.equal(cipher.output.toHex(), 'fce8b1ee8c6440d1');151 });152 // OpenSSL equivalent:153 // openssl enc -d -des-ede3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -nosalt154 it('should 3des-ecb decrypt: fce8b1ee8c6440d1', function() {155 var key = new UTIL.createBuffer(156 UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));157 var decipher = CIPHER.createDecipher('3DES-ECB', key);158 decipher.start();159 decipher.update(UTIL.createBuffer(UTIL.hexToBytes('fce8b1ee8c6440d1')));160 decipher.finish();161 ASSERT.equal(decipher.output.getBytes(), 'foobar');162 });163 // OpenSSL equivalent:164 // openssl enc -des3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -iv 818bcf76efc59662 -nosalt165 it('should 3des-cbc encrypt "foobar", restart, and encrypt "foobar,,"', function() {166 var key = new UTIL.createBuffer(167 UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));168 var iv = new UTIL.createBuffer(169 UTIL.hexToBytes('818bcf76efc59662'));170 var cipher = CIPHER.createCipher('3DES-CBC', key);171 cipher.start({iv: iv.copy()});172 cipher.update(UTIL.createBuffer('foobar'));173 cipher.finish();174 ASSERT.equal(cipher.output.toHex(), '209225f7687ca0b2');175 cipher.start({iv: iv.copy()});176 cipher.update(UTIL.createBuffer('foobar,,'));177 cipher.finish();178 ASSERT.equal(cipher.output.toHex(), '57156174c48dfc37293831bf192a6742');179 });180 // OpenSSL equivalent:181 // openssl enc -d -des3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -iv 818bcf76efc59662 -nosalt182 it('should 3des-cbc decrypt "209225f7687ca0b2", restart, and decrypt "57156174c48dfc37293831bf192a6742,,"', function() {183 var key = new UTIL.createBuffer(184 UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));185 var iv = new UTIL.createBuffer(186 UTIL.hexToBytes('818bcf76efc59662'));187 var decipher = CIPHER.createDecipher('3DES-CBC', key);188 decipher.start({iv: iv.copy()});189 decipher.update(UTIL.createBuffer(UTIL.hexToBytes('209225f7687ca0b2')));190 decipher.finish();191 ASSERT.equal(decipher.output.getBytes(), 'foobar');192 decipher.start({iv: iv.copy()});193 decipher.update(194 UTIL.createBuffer(UTIL.hexToBytes('57156174c48dfc37293831bf192a6742')));195 decipher.finish();196 ASSERT.equal(decipher.output.getBytes(), 'foobar,,');197 });198 });...
Using AI Code Generation
1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9MIT © [Shubham Kanodia](
Using AI Code Generation
1function createBuffer(bufferSize) {2 var buffer = new ArrayBuffer(bufferSize);3 var view = new Uint8Array(buffer);4 for (var i = 0; i < bufferSize; i++) {5 view[i] = i % 255;6 }7 return buffer;8}9function createBuffer2(bufferSize) {10 var buffer = new ArrayBuffer(bufferSize);11 var view = new Uint8Array(buffer);12 for (var i = 0; i < bufferSize; i++) {13 view[i] = i % 255;14 }15 return buffer;16}17function createBuffer3(bufferSize) {18 var buffer = new ArrayBuffer(bufferSize);19 var view = new Uint8Array(buffer);20 for (var i = 0; i < bufferSize; i++) {21 view[i] = i % 255;22 }23 return buffer;24}25function createBuffer4(bufferSize) {26 var buffer = new ArrayBuffer(bufferSize);27 var view = new Uint8Array(buffer);28 for (var i = 0; i < bufferSize; i++) {29 view[i] = i % 255;30 }31 return buffer;32}33function createBuffer5(bufferSize) {34 var buffer = new ArrayBuffer(bufferSize);35 var view = new Uint8Array(buffer);36 for (var i = 0; i < bufferSize; i++) {37 view[i] = i % 255;38 }39 return buffer;40}41function createBuffer6(bufferSize) {42 var buffer = new ArrayBuffer(bufferSize);43 var view = new Uint8Array(buffer);44 for (var i = 0; i < bufferSize; i++) {45 view[i] = i % 255;46 }47 return buffer;48}49function createBuffer7(bufferSize) {50 var buffer = new ArrayBuffer(bufferSize);51 var view = new Uint8Array(buffer);52 for (var i = 0; i < bufferSize; i++) {53 view[i] = i % 255;54 }55 return buffer;56}
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.runTest(url, options, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted to WebPageTest for %s', url);8 console.log('Test ID: %s', data.data.testId);9 console.log('Test status: %s', data.statusText);10});11wpt.getTestResults(data.data.testId, function(err, data) {12 if (err) return console.error(err);13 console.log('Test results for %s', url);14 console.log('First View (ms): %s', data.data.average.firstView.loadTime);15 console.log('Repeat View (ms): %s', data.data.average.repeatView.loadTime);16 console.log('Speed Index: %s', data.data.average.firstView.SpeedIndex);17 console.log('Video: %s', data.data.runs[1].firstView.videoFrames);18});
Using AI Code Generation
1var buffer = wpt.createBuffer(1024);2var buffer = wpt.readBuffer(1024);3var buffer = wpt.writeBuffer(1024);4var buffer = wpt.getBuffer(1024);5var buffer = wpt.setBuffer(1024);6var buffer = wpt.freeBuffer(1024);7var buffer = wpt.getBufferLength(1024);8var buffer = wpt.setBufferLength(1024);9var buffer = wpt.getBufferValue(1024);10var buffer = wpt.setBufferValue(1024);11var buffer = wpt.getBufferValueAt(1024);12var buffer = wpt.setBufferValueAt(1024);13var buffer = wpt.getBufferValues(1024);14var buffer = wpt.setBufferValues(1024);15var buffer = wpt.getBufferValuesAt(1024);16var buffer = wpt.setBufferValuesAt(1024);17var buffer = wpt.getBufferType(1024);
Using AI Code Generation
1const { createBuffer } = require('wptools');2const buffer = createBuffer();3buffer.write('hello world');4console.log(buffer.toString());5const { createBuffer } = require('wptools');6const buffer = createBuffer();7buffer.write('hello world');8console.log(buffer.toString());9const { createBuffer } = require('wptools');10const buffer = createBuffer();11buffer.write('hello world');12console.log(buffer.toString());13const { createBuffer } = require('wptools');14const buffer = createBuffer();15buffer.write('hello world');16console.log(buffer.toString());17const { createBuffer } = require('wptools');18const buffer = createBuffer();19buffer.write('hello world');20console.log(buffer.toString());21const { createBuffer } = require('wptools');22const buffer = createBuffer();23buffer.write('hello world');24console.log(buffer.toString());25const { createBuffer } = require('wptools');26const buffer = createBuffer();27buffer.write('hello world');28console.log(buffer.toString());29const { createBuffer } = require('wptools');30const buffer = createBuffer();31buffer.write('hello world');32console.log(buffer.toString());33const { createBuffer } = require('wptools');34const buffer = createBuffer();35buffer.write('hello world');36console.log(buffer.toString());37const { createBuffer } = require('wptools');38const buffer = createBuffer();
Using AI Code Generation
1var wpt = require('wpt');2var map = require('map');3var buffer = wpt.createBuffer(0, 0, 0.01);4var feature = map.createFeature(buffer);5map.addFeature(feature);6console.log(buffer);7console.log(feature);8console.log(map);9console.log(wpt);10console.log(wpt.createBuffer);11console.log(wpt.createBuffer());12console.log(wpt.createBuffer(0, 0, 0.01));13console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates());14console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0]);15console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0][0]);16console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0][0][0]);17console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0][0][1]);18console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0][0][2]);19console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0][0][3]);20console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0][0][4]);21console.log(wpt.createBuffer(0, 0, 0.01).getCoordinates()[0][0][5]);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!