How to use to_hex method in wpt

Best JavaScript code snippet using wpt

serializedtypes-test.js

Source:serializedtypes-test.js Github

copy

Full Screen

...13 "Int8" : {14 "Serialize 0" : function () {15 var so = new SerializedObject();16 types.Int8.serialize(so, 0);17 assert.equals(so.to_hex(), "00");18 },19 "Serialize 123" : function () {20 var so = new SerializedObject();21 types.Int8.serialize(so, 123);22 assert.equals(so.to_hex(), "7B");23 },24 "Serialize 255" : function () {25 var so = new SerializedObject();26 types.Int8.serialize(so, 255);27 assert.equals(so.to_hex(), "FF");28 },29 "Fail to serialize 256" : function () {30 var so = new SerializedObject();31 assert.exception(function () {32 types.Int8.serialize(so, 256);33 });34 },35 "Fail to serialize -1" : function () {36 var so = new SerializedObject();37 assert.exception(function () {38 types.Int8.serialize(so, -1);39 });40 },41 "Serialize 5.5 (should floor)" : function () {42 var so = new SerializedObject();43 types.Int8.serialize(so, 5.5);44 assert.equals(so.to_hex(), "05");45 },46 "Serialize 255.9 (should floor)" : function () {47 var so = new SerializedObject();48 types.Int8.serialize(so, 255.9);49 assert.equals(so.to_hex(), "FF");50 },51 "Fail to serialize null" : function () {52 var so = new SerializedObject();53 assert.exception(function () {54 types.Int8.serialize(so, null);55 });56 },57 "Fail to serialize 'bla'" : function () {58 var so = new SerializedObject();59 assert.exception(function () {60 types.Int8.serialize(so, 'bla');61 });62 },63 "Fail to serialize {}" : function () {64 var so = new SerializedObject();65 assert.exception(function () {66 types.Int8.serialize(so, {});67 });68 }69 },70 "Int16" : {71 "Serialize 0" : function () {72 var so = new SerializedObject();73 types.Int16.serialize(so, 0);74 assert.equals(so.to_hex(), "0000");75 },76 "Serialize 123" : function () {77 var so = new SerializedObject();78 types.Int16.serialize(so, 123);79 assert.equals(so.to_hex(), "007B");80 },81 "Serialize 255" : function () {82 var so = new SerializedObject();83 types.Int16.serialize(so, 255);84 assert.equals(so.to_hex(), "00FF");85 },86 "Serialize 256" : function () {87 var so = new SerializedObject();88 types.Int16.serialize(so, 256);89 assert.equals(so.to_hex(), "0100");90 },91 "Serialize 65535" : function () {92 var so = new SerializedObject();93 types.Int16.serialize(so, 65535);94 assert.equals(so.to_hex(), "FFFF");95 },96 "Fail to serialize 65536" : function () {97 var so = new SerializedObject();98 assert.exception(function () {99 types.Int8.serialize(so, 65536);100 });101 },102 "Fail to serialize -1" : function () {103 var so = new SerializedObject();104 assert.exception(function () {105 types.Int16.serialize(so, -1);106 });107 },108 "Serialize 123.5 (should floor)" : function () {109 var so = new SerializedObject();110 types.Int16.serialize(so, 123.5);111 assert.equals(so.to_hex(), "007B");112 },113 "Serialize 65535.5 (should floor)" : function () {114 var so = new SerializedObject();115 types.Int16.serialize(so, 65535.5);116 assert.equals(so.to_hex(), "FFFF");117 },118 "Fail to serialize null" : function () {119 var so = new SerializedObject();120 assert.exception(function () {121 types.Int16.serialize(so, null);122 });123 },124 "Fail to serialize 'bla'" : function () {125 var so = new SerializedObject();126 assert.exception(function () {127 types.Int16.serialize(so, 'bla');128 });129 },130 "Fail to serialize {}" : function () {131 var so = new SerializedObject();132 assert.exception(function () {133 types.Int16.serialize(so, {});134 });135 }136 },137 "Int32" : {138 "Serialize 0" : function () {139 var so = new SerializedObject();140 types.Int32.serialize(so, 0);141 assert.equals(so.to_hex(), "00000000");142 },143 "Serialize 123" : function () {144 var so = new SerializedObject();145 types.Int32.serialize(so, 123);146 assert.equals(so.to_hex(), "0000007B");147 },148 "Serialize 255" : function () {149 var so = new SerializedObject();150 types.Int32.serialize(so, 255);151 assert.equals(so.to_hex(), "000000FF");152 },153 "Serialize 256" : function () {154 var so = new SerializedObject();155 types.Int32.serialize(so, 256);156 assert.equals(so.to_hex(), "00000100");157 },158 "Serialize 0xF0F0F0F0" : function () {159 var so = new SerializedObject();160 types.Int32.serialize(so, 0xF0F0F0F0);161 assert.equals(so.to_hex(), "F0F0F0F0");162 },163 "Serialize 0xFFFFFFFF" : function () {164 var so = new SerializedObject();165 types.Int32.serialize(so, 0xFFFFFFFF);166 assert.equals(so.to_hex(), "FFFFFFFF");167 },168 "Fail to serialize 0x100000000" : function () {169 var so = new SerializedObject();170 assert.exception(function () {171 types.Int8.serialize(so, 0x100000000);172 });173 },174 "Fail to serialize -1" : function () {175 var so = new SerializedObject();176 assert.exception(function () {177 types.Int32.serialize(so, -1);178 });179 },180 "Serialize 123.5 (should floor)" : function () {181 var so = new SerializedObject();182 types.Int32.serialize(so, 123.5);183 assert.equals(so.to_hex(), "0000007B");184 },185 "Serialize 4294967295.5 (should floor)" : function () {186 var so = new SerializedObject();187 types.Int32.serialize(so, 4294967295.5);188 assert.equals(so.to_hex(), "FFFFFFFF");189 },190 "Fail to serialize null" : function () {191 var so = new SerializedObject();192 assert.exception(function () {193 types.Int32.serialize(so, null);194 });195 },196 "Fail to serialize 'bla'" : function () {197 var so = new SerializedObject();198 assert.exception(function () {199 types.Int32.serialize(so, 'bla');200 });201 },202 "Fail to serialize {}" : function () {203 var so = new SerializedObject();204 assert.exception(function () {205 types.Int32.serialize(so, {});206 });207 }208 },209 "Int64" : {210 "Serialize 0" : function () {211 var so = new SerializedObject();212 types.Int64.serialize(so, 0);213 assert.equals(so.to_hex(), "0000000000000000");214 },215 "Serialize 123" : function () {216 var so = new SerializedObject();217 types.Int64.serialize(so, 123);218 assert.equals(so.to_hex(), "000000000000007B");219 },220 "Serialize 255" : function () {221 var so = new SerializedObject();222 types.Int64.serialize(so, 255);223 assert.equals(so.to_hex(), "00000000000000FF");224 },225 "Serialize 256" : function () {226 var so = new SerializedObject();227 types.Int64.serialize(so, 256);228 assert.equals(so.to_hex(), "0000000000000100");229 },230 "Serialize 0xF0F0F0F0" : function () {231 var so = new SerializedObject();232 types.Int64.serialize(so, 0xF0F0F0F0);233 assert.equals(so.to_hex(), "00000000F0F0F0F0");234 },235 "Serialize 0xFFFFFFFF" : function () {236 var so = new SerializedObject();237 types.Int64.serialize(so, 0xFFFFFFFF);238 assert.equals(so.to_hex(), "00000000FFFFFFFF");239 },240 "Serialize 0x100000000" : function () {241 var so = new SerializedObject();242 types.Int64.serialize(so, 0x100000000);243 assert.equals(so.to_hex(), "0000000100000000");244 },245 "Fail to serialize 0x100000000" : function () {246 var so = new SerializedObject();247 assert.exception(function () {248 types.Int8.serialize(so, 0x100000000);249 });250 },251 "Fail to serialize -1" : function () {252 var so = new SerializedObject();253 assert.exception(function () {254 types.Int64.serialize(so, -1);255 });256 },257 "Serialize 123.5 (should floor)" : function () {258 var so = new SerializedObject();259 types.Int64.serialize(so, 123.5);260 assert.equals(so.to_hex(), "000000000000007B");261 },262 "Serialize 4294967295.5 (should floor)" : function () {263 var so = new SerializedObject();264 types.Int64.serialize(so, 4294967295.5);265 assert.equals(so.to_hex(), "00000000FFFFFFFF");266 },267 "Serialize '0123456789ABCDEF'" : function () {268 var so = new SerializedObject();269 types.Int64.serialize(so, "0123456789ABCDEF");270 assert.equals(so.to_hex(), "0123456789ABCDEF");271 },272 "Serialize 'F0E1D2C3B4A59687'" : function () {273 var so = new SerializedObject();274 types.Int64.serialize(so, "F0E1D2C3B4A59687");275 assert.equals(so.to_hex(), "F0E1D2C3B4A59687");276 },277 "Serialize BigInteger('FFEEDDCCBBAA9988')" : function () {278 var so = new SerializedObject();279 types.Int64.serialize(so, new BigInteger("FFEEDDCCBBAA9988", 16));280 assert.equals(so.to_hex(), "FFEEDDCCBBAA9988");281 },282 "Fail to serialize BigInteger('-1')" : function () {283 var so = new SerializedObject();284 assert.exception(function () {285 types.Int64.serialize(so, new BigInteger("-1", 10));286 });287 },288 "Fail to serialize '10000000000000000'" : function () {289 var so = new SerializedObject();290 assert.exception(function () {291 types.Int64.serialize(so, "10000000000000000");292 });293 },294 "Fail to serialize '110000000000000000'" : function () {295 var so = new SerializedObject();296 assert.exception(function () {297 types.Int64.serialize(so, "110000000000000000");298 });299 },300 "Fail to serialize null" : function () {301 var so = new SerializedObject();302 assert.exception(function () {303 types.Int64.serialize(so, null);304 });305 },306 "Fail to serialize 'bla'" : function () {307 var so = new SerializedObject();308 assert.exception(function () {309 types.Int64.serialize(so, 'bla');310 });311 },312 "Fail to serialize {}" : function () {313 var so = new SerializedObject();314 assert.exception(function () {315 types.Int64.serialize(so, {});316 });317 }318 },319 "Hash128" : {320 "Serialize 0" : function () {321 var so = new SerializedObject();322 types.Hash128.serialize(so, "00000000000000000000000000000000");323 assert.equals(so.to_hex(), "00000000000000000000000000000000");324 },325 "Serialize 102030405060708090A0B0C0D0E0F000" : function () {326 var so = new SerializedObject();327 types.Hash128.serialize(so, "102030405060708090A0B0C0D0E0F000");328 assert.equals(so.to_hex(), "102030405060708090A0B0C0D0E0F000");329 },330 "Serialize FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" : function () {331 var so = new SerializedObject();332 types.Hash128.serialize(so, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");333 assert.equals(so.to_hex(), "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");334 },335 },336 "Hash160" : {337 "Serialize 0" : function () {338 var so = new SerializedObject();339 types.Hash160.serialize(so, "rrrrrrrrrrrrrrrrrrrrrhoLvTp");340 assert.equals(so.to_hex(), "0000000000000000000000000000000000000000");341 },342 "Serialize 1" : function () {343 var so = new SerializedObject();344 types.Hash160.serialize(so, "rrrrrrrrrrrrrrrrrrrrBZbvji");345 assert.equals(so.to_hex(), "0000000000000000000000000000000000000001");346 },347 "Serialize FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" : function () {348 var so = new SerializedObject();349 types.Hash160.serialize(so, "rQLbzfJH5BT1FS9apRLKV3G8dWEA5njaQi");350 assert.equals(so.to_hex(), "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");351 },352 },353 "Amount" : {354 "Serialize 0 XRP" : function () {355 var so = new SerializedObject();356 types.Amount.serialize(so, "0");357 assert.equals(so.to_hex(), "4000000000000000");358 },359 "Serialize 1 XRP" : function () {360 var so = new SerializedObject();361 types.Amount.serialize(so, "1");362 assert.equals(so.to_hex(), "4000000000000001");363 },364 "Serialize -1 XRP" : function () {365 var so = new SerializedObject();366 types.Amount.serialize(so, "-1");367 assert.equals(so.to_hex(), "0000000000000001");368 },369 "Serialize 213 XRP" : function () {370 var so = new SerializedObject();371 types.Amount.serialize(so, "213");372 assert.equals(so.to_hex(), "40000000000000D5");373 },374 "Serialize 270544960 XRP" : function () {375 var so = new SerializedObject();376 types.Amount.serialize(so, "270544960");377 assert.equals(so.to_hex(), "4000000010203040");378 },379 "Serialize 1161981756646125568 XRP" : function () {380 var so = new SerializedObject();381 types.Amount.serialize(so, "1161981756646125696");382 assert.equals(so.to_hex(), "5020304050607080");383 },384 "Serialize 1/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" : function () {385 var so = new SerializedObject();386 types.Amount.serialize(so, "1/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh");387 assert.equals(so.to_hex(), "D4838D7EA4C680000000000000000000000000005553440000000000B5F762798A53D543A014CAF8B297CFF8F2F937E8");388 },389 "Serialize 87654321.12345678/EUR/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" : function () {390 var so = new SerializedObject();391 types.Amount.serialize(so, "87654321.12345678/EUR/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh");392 assert.equals(so.to_hex(), "D65F241D335BF24E0000000000000000000000004555520000000000B5F762798A53D543A014CAF8B297CFF8F2F937E8");393 },394 "Serialize -1/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" : function () {395 var so = new SerializedObject();396 types.Amount.serialize(so, "-1/USD/rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh");397 assert.equals(so.to_hex(), "94838D7EA4C680000000000000000000000000005553440000000000B5F762798A53D543A014CAF8B297CFF8F2F937E8");398 },399 "Parse 1 XRP" : function () {400 var so = new SerializedObject("4000000000000001");401 assert.equals(types.Amount.parse(so).to_json(), "1");402 },403 "Parse -1 XRP" : function () {404 var so = new SerializedObject("0000000000000001");405 assert.equals(types.Amount.parse(so).to_json(), "-1");406 },407 "Parse 213 XRP" : function () {408 var so = new SerializedObject("40000000000000D5");409 assert.equals(types.Amount.parse(so).to_json(), "213");410 },411 "Parse 270544960 XRP" : function () {...

Full Screen

Full Screen

tests.js

Source:tests.js Github

copy

Full Screen

...10function wouldBeRandomInARealProgram(howmuch) {11 return new Uint8Array(howmuch);12}13suite.utf8Encoding = function () {14 assert.equal(nacl.to_hex(nacl.encode_utf8("\xe5\xe4\xf6")), "c3a5c3a4c3b6");15};16suite.hexEncoding = function () {17 assert.equal(nacl.to_hex(nacl.encode_utf8("hello")), "68656c6c6f");18};19suite.hexDecoding = function () {20 assert.equal(nacl.decode_utf8(nacl.from_hex("68656c6c6f")), "hello");21 assert.equal(nacl.decode_utf8(nacl.from_hex("68656C6C6F")), "hello");22};23suite.hashing = function () {24 assert.equal(nacl.to_hex(nacl.crypto_hash_string("hello")),25 "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca7"+26 "2323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043");27 assert.equal(nacl.to_hex(nacl.crypto_hash(nacl.encode_utf8("hello"))),28 "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca7"+29 "2323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043");30 assert.equal(nacl.to_hex(nacl.crypto_hash_sha256(nacl.encode_utf8("hello"))),31 "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824");32};33suite.boxKeypairFromSeed = function () {34 var seed = nacl.encode_utf8("hello");35 var kp = nacl.crypto_box_keypair_from_seed(seed);36 assert.equal(nacl.to_hex(kp.boxPk),37 "d8333ecf53dac465d59f3b03878ceff88947eec57c965105a049a0f5f1b7a510");38 assert.equal(nacl.to_hex(kp.boxSk),39 "9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca7");40 var selfDHkey = nacl.crypto_box_precompute(kp.boxPk, kp.boxSk);41 assert.equal(nacl.to_hex(selfDHkey.boxK),42 "9f6c32cd88662c3cfc7e41c8f8b06960c71e560c35b693966085a68317b4cce9");43};44suite.randomBoxNonceLength = function () {45 assert.equal(nacl.crypto_box_random_nonce().length, nacl.crypto_box_NONCEBYTES);46};47suite.precomputedBox = function () {48 var seed = nacl.encode_utf8("hello");49 var kp = nacl.crypto_box_keypair_from_seed(seed);50 var selfShared = nacl.crypto_box_precompute(kp.boxPk, kp.boxSk);51 var nonce = wouldBeRandomInARealProgram(nacl.crypto_box_NONCEBYTES);52 var plaintext = "box test";53 var c = nacl.crypto_box_precomputed(nacl.encode_utf8(plaintext), nonce, selfShared);54 assert.equal(nacl.to_hex(c), "1ac48540344a19bd9516a2ea01d99f889dc97a47ba58946d");55 var m = nacl.crypto_box_open_precomputed(c, nonce, selfShared);56 assert.equal(nacl.decode_utf8(m), plaintext);57};58suite.normalBox = function () {59 var seed = nacl.encode_utf8("hello");60 var kp = nacl.crypto_box_keypair_from_seed(seed);61 var nonce = wouldBeRandomInARealProgram(nacl.crypto_box_NONCEBYTES);62 var plaintext = "box test";63 var c = nacl.crypto_box(nacl.encode_utf8(plaintext), nonce, kp.boxPk, kp.boxSk);64 assert.equal(nacl.to_hex(c), "1ac48540344a19bd9516a2ea01d99f889dc97a47ba58946d");65 var m = nacl.crypto_box_open(c, nonce, kp.boxPk, kp.boxSk);66 assert.equal(nacl.decode_utf8(m), plaintext);67};68suite.stream = function () {69 var n = wouldBeRandomInARealProgram(nacl.crypto_stream_NONCEBYTES);70 var k = wouldBeRandomInARealProgram(nacl.crypto_stream_KEYBYTES);71 assert.equal(nacl.to_hex(nacl.crypto_stream(10, n, k)), "ba6e26df4b2ea2cf64d2");72 var c = nacl.crypto_stream_xor(nacl.encode_utf8("hello"), n, k);73 assert.equal(nacl.to_hex(c), "d20b4ab324");74 var m = nacl.crypto_stream_xor(c, n, k);75 assert.equal(nacl.decode_utf8(m), "hello");76};77suite.onetimeAuth = function () {78 var authkey =79 nacl.crypto_hash(nacl.encode_utf8("hello")).subarray(0, nacl.crypto_onetimeauth_KEYBYTES);80 var auth = nacl.crypto_onetimeauth(nacl.encode_utf8("hello"), authkey);81 assert.equal(nacl.to_hex(auth), "8acf9be1c2048a66ae442c83f2ae21c1");82 assert.ok(nacl.crypto_onetimeauth_verify(auth, nacl.encode_utf8("hello"), authkey));83 assert.equal(nacl.crypto_onetimeauth_verify(auth,84 nacl.encode_utf8("hellp"), // <==85 authkey),86 false);87 assert.equal(nacl.crypto_onetimeauth_verify(auth.subarray(1), // <==88 nacl.encode_utf8("hello"),89 authkey),90 false);91 auth[0] = auth[0] + 1;92 assert.equal(nacl.crypto_onetimeauth_verify(auth, // <== modified93 nacl.encode_utf8("hello"),94 authkey),95 false);96};97suite.auth = function () {98 var authkey =99 nacl.crypto_hash(nacl.encode_utf8("hello")).subarray(0, nacl.crypto_auth_KEYBYTES);100 var auth = nacl.crypto_auth(nacl.encode_utf8("hello"), authkey);101 assert.equal(nacl.to_hex(auth),102 "3363a029b88688109b420ea8bed190228893c3fc85c18bf0dc4a1d14b4ce57fd");103 assert.ok(nacl.crypto_auth_verify(auth, nacl.encode_utf8("hello"), authkey));104 assert.equal(nacl.crypto_auth_verify(auth, nacl.encode_utf8("hellp"), authkey), false);105 assert.equal(nacl.crypto_auth_verify(auth.subarray(1), nacl.encode_utf8("hello"), authkey),106 false);107 auth[0] = auth[0] + 1;108 assert.equal(nacl.crypto_auth_verify(auth, nacl.encode_utf8("hello"), authkey), false);109};110suite.secretBox = function () {111 var n = wouldBeRandomInARealProgram(nacl.crypto_secretbox_NONCEBYTES);112 var secretboxkey =113 nacl.crypto_hash(nacl.encode_utf8("thekey")).subarray(0, nacl.crypto_secretbox_KEYBYTES);114 var plaintext = "hello";115 var c = nacl.crypto_secretbox(nacl.encode_utf8(plaintext), n, secretboxkey);116 assert.equal(nacl.to_hex(c), "08877931f3041765b847df995236a3c6b799cabe24");117 var m = nacl.crypto_secretbox_open(c, n, secretboxkey);118 assert.equal(nacl.decode_utf8(m), plaintext);119};120suite.signatures = function () {121 var seedlen = nacl.crypto_sign_SECRETKEYBYTES / 2; // probably should be defined as a constant122 var seed = nacl.crypto_hash_string("This is my passphrase").subarray(0, seedlen);123 assert.equal(nacl.to_hex(seed),124 "2268afda5a2a900cf07bdbaa05312a958b54e25c8042157840b8e79386512af1");125 var kp = nacl.crypto_sign_keypair_from_seed(seed);126 assert.equal(nacl.to_hex(kp.signPk),127 "ba1000e3fe1213a53129e2d071c5e55a9afcad1c355fae453dd4dd2e7aaac242");128 assert.equal(nacl.to_hex(kp.signSk),129 "2268afda5a2a900cf07bdbaa05312a958b54e25c8042157840b8e79386512af1"+130 "ba1000e3fe1213a53129e2d071c5e55a9afcad1c355fae453dd4dd2e7aaac242");131 var message = "message";132 var c = nacl.crypto_sign(nacl.encode_utf8(message), kp.signSk);133 assert.equal(nacl.to_hex(c),134 "d11d1612189ce965201e839bd007e2fe5f726a7ddc54ea3fba41f7d14207b542"+135 "f60c6fee4eca64b630ef0d450b2ea0a72bdf5f526f5678ee55b979f368c52f0a"+136 "6d657373616765");137 var detached_sig = nacl.crypto_sign_detached(nacl.encode_utf8(message), kp.signSk);138 assert.equal(nacl.to_hex(detached_sig),139 "d11d1612189ce965201e839bd007e2fe5f726a7ddc54ea3fba41f7d14207b542"+140 "f60c6fee4eca64b630ef0d450b2ea0a72bdf5f526f5678ee55b979f368c52f0a");141 var m = nacl.crypto_sign_open(c, kp.signPk);142 assert.notEqual(m, null);143 assert.equal(nacl.decode_utf8(m), message);144 assert.ok(nacl.crypto_sign_verify_detached(detached_sig, nacl.encode_utf8(message), kp.signPk));145 // Corrupt the signature146 c = nacl.decode_latin1(c);147 c = c.substring(0, 35) + '!' + c.substring(36);148 c = nacl.encode_latin1(c);149 m = nacl.crypto_sign_open(c, kp.signPk);150 assert.equal(m, null);151 // Corrupt the detached signature152 detached_sig = nacl.decode_latin1(detached_sig);153 detached_sig = detached_sig.substring(0, 35) + '!' + detached_sig.substring(36);154 detached_sig = nacl.encode_latin1(detached_sig);155 assert.equal(nacl.crypto_sign_verify_detached(detached_sig,156 nacl.encode_utf8(message),157 kp.signPk),158 false);159};160suite.randomBoxKeyRoundtrip = function () {161 var kp = nacl.crypto_box_keypair_from_raw_sk(nacl.random_bytes(nacl.crypto_box_SECRETKEYBYTES));162 var n = nacl.crypto_box_random_nonce();163 var message = "message";164 assert.equal(nacl.decode_utf8(nacl.crypto_box_open(nacl.crypto_box(nacl.encode_utf8(message),165 n, kp.boxPk, kp.boxSk),166 n, kp.boxPk, kp.boxSk)),167 message);168};169suite.curve25519_correctness = function () {170 // Check correctness of curve25519 via NaCl test vector171 var alice_private =172 nacl.from_hex("77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a");173 var bob_public =174 nacl.from_hex("de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f");175 assert.equal(nacl.to_hex(nacl.crypto_scalarmult(alice_private,bob_public)),176 "4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742");177};178suite.randomSignKeyRoundtrip = function () {179 var kp = nacl.crypto_sign_keypair();180 var message = "message";181 assert.equal(nacl.decode_utf8(nacl.crypto_sign_open(nacl.crypto_sign(nacl.encode_utf8(message),182 kp.signSk),183 kp.signPk)),184 message);185 assert.ok(nacl.crypto_sign_verify_detached(nacl.crypto_sign_detached(nacl.encode_utf8(message),186 kp.signSk),187 nacl.encode_utf8(message),188 kp.signPk));189};190suite.seededBoxKeypairIdentities1 = function () {191 var kp1 = nacl.crypto_box_keypair();192 var kp2 = nacl.crypto_box_keypair_from_raw_sk(kp1.boxSk);193 assert.equal(nacl.to_hex(kp2.boxPk), nacl.to_hex(kp1.boxPk));194 assert.equal(nacl.to_hex(kp2.boxSk), nacl.to_hex(kp1.boxSk));195};196suite.seededBoxKeypairIdentities2 = function () {197 var seed = nacl.encode_utf8("the seed");198 var sk = nacl.crypto_hash(seed).subarray(0, nacl.crypto_box_SECRETKEYBYTES);199 var kp = nacl.crypto_box_keypair_from_seed(seed);200 assert.equal(nacl.to_hex(kp.boxSk), nacl.to_hex(sk));201};202suite.seededSignKeypairIdentities1 = function () {203 var seedlen = nacl.crypto_sign_SECRETKEYBYTES / 2; // probably should be defined as a constant204 var kp1 = nacl.crypto_sign_keypair();205 var kp2 = nacl.crypto_sign_keypair_from_seed(kp1.signSk.subarray(0, seedlen));206 assert.equal(nacl.to_hex(kp2.signPk), nacl.to_hex(kp1.signPk));207 assert.equal(nacl.to_hex(kp2.signSk), nacl.to_hex(kp1.signSk));208};209suite.seededSignKeypairIdentities2 = function () {210 var seedlen = nacl.crypto_sign_SECRETKEYBYTES / 2; // probably should be defined as a constant211 var seed = nacl.crypto_hash(nacl.encode_utf8("the seed")).subarray(0, seedlen);212 var kp = nacl.crypto_sign_keypair_from_seed(seed);213 assert.equal(nacl.to_hex(kp.signSk.subarray(0, seedlen)), nacl.to_hex(seed));...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest(url, { location: 'Dulles_MotoG4:Chrome', connectivity: '3G' }, function(err, data) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log('Test ID: ' + data.data.testId);8 console.log('Test URL: ' + data.data.userUrl);9 }10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13wpt.runTest(url, { location: 'Dulles_MotoG4:Chrome', connectivity: '3G' }, function(err, data) {14 if (err) {15 console.log('Error: ' + err);16 } else {17 console.log('Test ID: ' + data.data.testId);18 console.log('Test URL: ' + data.data.userUrl);19 }20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require("wpt");2var hex = wpt.to_hex(1234);3console.log(hex);4var wpt = require("wpt");5var hex = wpt.to_hex(1234);6console.log(hex);7var wpt = require("wpt");8var hex = wpt.to_hex(1234);9console.log(hex);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptb = require('wptb');2var hex = wptb.to_hex('Hello World');3console.log(hex);4var wptb = require('wptb');5var hex = wptb.to_hex('Hello World');6console.log(hex);7var wptb = require('wptb');8var hex = wptb.to_hex('Hello World');9console.log(hex);10var wptb = require('wptb');11var hex = wptb.to_hex('Hello World');12console.log(hex);13var wptb = require('wptb');14var hex = wptb.to_hex('Hello World');15console.log(hex);16var wptb = require('wptb');17var hex = wptb.to_hex('Hello World');18console.log(hex);19var wptb = require('wptb');20var hex = wptb.to_hex('Hello World');21console.log(hex);22var wptb = require('wptb');23var hex = wptb.to_hex('Hello World');24console.log(hex);25var wptb = require('wptb');26var hex = wptb.to_hex('Hello World');27console.log(hex);28var wptb = require('wptb');29var hex = wptb.to_hex('Hello World');30console.log(hex);31var wptb = require('wptb');32var hex = wptb.to_hex('Hello World');33console.log(hex);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var hex = wpt.to_hex(100);3console.log(hex);4var wpt = require('wpt');5var hex = wpt.to_hex(100);6console.log(hex);7var wpt = require('wpt');8var hex = wpt.to_hex(100);9console.log(hex);10var wpt = require('wpt');11var hex = wpt.to_hex(100);12console.log(hex);13var wpt = require('wpt');14var hex = wpt.to_hex(100);15console.log(hex);16var wpt = require('wpt');17var hex = wpt.to_hex(100);18console.log(hex);19var wpt = require('wpt');20var hex = wpt.to_hex(100);21console.log(hex);22var wpt = require('wpt');23var hex = wpt.to_hex(100);24console.log(hex);25var wpt = require('wpt');26var hex = wpt.to_hex(100);27console.log(hex);28var wpt = require('wpt');29var hex = wpt.to_hex(100);30console.log(hex);31var wpt = require('wpt');32var hex = wpt.to_hex(100);33console.log(hex);34var wpt = require('wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var to_hex = wpt.to_hex;3var a = to_hex(255, 255, 255);4var b = to_hex(0, 0, 0);5var c = to_hex(255, 0, 0);6var d = to_hex(0, 255, 0);7var e = to_hex(0, 0, 255);8var f = to_hex(255, 255, 0);9var g = to_hex(255, 0, 255);10var h = to_hex(0, 255, 255);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var toHex = wptools.toHex;3var str = 'test';4console.log(toHex(str));5var wptools = require('wptools');6var toHex = wptools.toHex;7var str = 'test';8console.log(toHex(str));9var wptools = require('wptools');10var toHex = wptools.toHex;11var str = 'test';12console.log(toHex(str));13var wptools = require('wptools');14var toHex = wptools.toHex;15var str = 'test';16console.log(toHex(str));17var wptools = require('wptools');18var toHex = wptools.toHex;19var str = 'test';20console.log(toHex(str));21var wptools = require('wptools');22var toHex = wptools.toHex;23var str = 'test';24console.log(toHex(str));25var wptools = require('wptools');26var toHex = wptools.toHex;27var str = 'test';28console.log(toHex(str));29var wptools = require('wptools');30var toHex = wptools.toHex;31var str = 'test';32console.log(toHex(str));33var wptools = require('wptools');34var toHex = wptools.toHex;35var str = 'test';36console.log(toHex(str));37var wptools = require('wptools');38var toHex = wptools.toHex;39var str = 'test';40console.log(toHex(str));

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var hex = wpt.to_hex('hello world');3console.log(hex);4require(['wpt'], function(wpt){5 var hex = wpt.to_hex('hello world');6 console.log(hex);7});8var wpt = require('wpt');9var hex = wpt.to_hex('hello world');10console.log(hex);11require(['wpt'], function(wpt){12 var hex = wpt.to_hex('hello world');13 console.log(hex);14});15var wpt = require('wpt');16var hex = wpt.to_hex('hello world');17console.log(hex);18require(['wpt'], function(wpt){19 var hex = wpt.to_hex('hello world');20 console.log(hex);21});22var wpt = require('wpt');23var hex = wpt.to_hex('hello world');24console.log(hex);25require(['wpt'], function(wpt){26 var hex = wpt.to_hex('hello world');27 console.log(hex);28});29var wpt = require('wpt');30var hex = wpt.to_hex('hello world');31console.log(hex);32require(['wpt'], function(wpt){33 var hex = wpt.to_hex('hello world');34 console.log(hex);35});36var wpt = require('wpt');37var hex = wpt.to_hex('hello world');38console.log(hex);39require(['wpt'], function(wpt){40 var hex = wpt.to_hex('hello world');41 console.log(hex);42});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptb = require('./index.js');2var hex = wptb.to_hex('test');3console.log(hex);4var wptb = require('./wptb.js');5wptb.to_hex = function(string) {6 var hex = '';7 for(var i=0;i<string.length;i++) {8 hex += ''+string.charCodeAt(i).toString(16);9 }10 return hex;11}12module.exports = wptb;13var wptb = {};14module.exports = wptb;

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful