How to use Word64 method in wpt

Best JavaScript code snippet using wpt

crypto.js

Source:crypto.js Github

copy

Full Screen

...137 }138 return hash;139})();140var Word64 = (function Word64Closure() {141 function Word64(highInteger, lowInteger) {142 this.high = highInteger | 0;143 this.low = lowInteger | 0;144 }145 Word64.prototype = {146 and: function Word64_and(word) {147 this.high &= word.high;148 this.low &= word.low;149 },150 xor: function Word64_xor(word) {151 this.high ^= word.high;152 this.low ^= word.low;153 },154 or: function Word64_or(word) {155 this.high |= word.high;156 this.low |= word.low;157 },158 shiftRight: function Word64_shiftRight(places) {159 if (places >= 32) {160 this.low = (this.high >>> (places - 32)) | 0;161 this.high = 0;162 } else {163 this.low = (this.low >>> places) | (this.high << (32 - places));164 this.high = (this.high >>> places) | 0;165 }166 },167 shiftLeft: function Word64_shiftLeft(places) {168 if (places >= 32) {169 this.high = this.low << (places - 32);170 this.low = 0;171 } else {172 this.high = (this.high << places) | (this.low >>> (32 - places));173 this.low = this.low << places;174 }175 },176 rotateRight: function Word64_rotateRight(places) {177 var low, high;178 if (places & 32) {179 high = this.low;180 low = this.high;181 } else {182 low = this.low;183 high = this.high;184 }185 places &= 31;186 this.low = (low >>> places) | (high << (32 - places));187 this.high = (high >>> places) | (low << (32 - places));188 },189 not: function Word64_not() {190 this.high = ~this.high;191 this.low = ~this.low;192 },193 add: function Word64_add(word) {194 var lowAdd = (this.low >>> 0) + (word.low >>> 0);195 var highAdd = (this.high >>> 0) + (word.high >>> 0);196 if (lowAdd > 0xFFFFFFFF) {197 highAdd += 1;198 }199 this.low = lowAdd | 0;200 this.high = highAdd | 0;201 },202 copyTo: function Word64_copyTo(bytes, offset) {203 bytes[offset] = (this.high >>> 24) & 0xFF;204 bytes[offset + 1] = (this.high >> 16) & 0xFF;205 bytes[offset + 2] = (this.high >> 8) & 0xFF;206 bytes[offset + 3] = this.high & 0xFF;207 bytes[offset + 4] = (this.low >>> 24) & 0xFF;208 bytes[offset + 5] = (this.low >> 16) & 0xFF;209 bytes[offset + 6] = (this.low >> 8) & 0xFF;210 bytes[offset + 7] = this.low & 0xFF;211 },212 assign: function Word64_assign(word) {213 this.high = word.high;214 this.low = word.low;215 }216 };217 return Word64;218})();219var calculateSHA256 = (function calculateSHA256Closure() {220 function rotr(x, n) {221 return (x >>> n) | (x << 32 - n);222 }223 function ch(x, y, z) {224 return (x & y) ^ (~x & z);225 }226 function maj(x, y, z) {227 return (x & y) ^ (x & z) ^ (y & z);228 }229 function sigma(x) {230 return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);231 }232 function sigmaPrime(x) {233 return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);234 }235 function littleSigma(x) {236 return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;237 }238 function littleSigmaPrime(x) {239 return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;240 }241 var k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,242 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,243 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,244 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,245 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,246 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,247 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,248 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,249 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,250 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,251 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,252 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,253 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,254 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,255 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,256 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];257 function hash(data, offset, length) {258 // initial hash values259 var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372,260 h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c,261 h6 = 0x1f83d9ab, h7 = 0x5be0cd19;262 // pre-processing263 var paddedLength = Math.ceil((length + 9) / 64) * 64;264 var padded = new Uint8Array(paddedLength);265 var i, j, n;266 for (i = 0; i < length; ++i) {267 padded[i] = data[offset++];268 }269 padded[i++] = 0x80;270 n = paddedLength - 8;271 while (i < n) {272 padded[i++] = 0;273 }274 padded[i++] = 0;275 padded[i++] = 0;276 padded[i++] = 0;277 padded[i++] = (length >>> 29) & 0xFF;278 padded[i++] = (length >> 21) & 0xFF;279 padded[i++] = (length >> 13) & 0xFF;280 padded[i++] = (length >> 5) & 0xFF;281 padded[i++] = (length << 3) & 0xFF;282 var w = new Uint32Array(64);283 // for each 512 bit block284 for (i = 0; i < paddedLength;) {285 for (j = 0; j < 16; ++j) {286 w[j] = (padded[i] << 24 | (padded[i + 1] << 16) |287 (padded[i + 2] << 8) | (padded[i + 3]));288 i += 4;289 }290 for (j = 16; j < 64; ++j) {291 w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] +292 littleSigma(w[j - 15]) + w[j - 16] | 0;293 }294 var a = h0, b = h1, c = h2, d = h3, e = h4,295 f = h5, g = h6, h = h7, t1, t2;296 for (j = 0; j < 64; ++j) {297 t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];298 t2 = sigma(a) + maj(a, b, c);299 h = g;300 g = f;301 f = e;302 e = (d + t1) | 0;303 d = c;304 c = b;305 b = a;306 a = (t1 + t2) | 0;307 }308 h0 = (h0 + a) | 0;309 h1 = (h1 + b) | 0;310 h2 = (h2 + c) | 0;311 h3 = (h3 + d) | 0;312 h4 = (h4 + e) | 0;313 h5 = (h5 + f) | 0;314 h6 = (h6 + g) | 0;315 h7 = (h7 + h) | 0;316 }317 return new Uint8Array([318 (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, (h0) & 0xFF,319 (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, (h1) & 0xFF,320 (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, (h2) & 0xFF,321 (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, (h3) & 0xFF,322 (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, (h4) & 0xFF,323 (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, (h5) & 0xFF,324 (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, (h6) & 0xFF,325 (h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, (h7) & 0xFF326 ]);327 }328 return hash;329})();330var calculateSHA512 = (function calculateSHA512Closure() {331 function ch(result, x, y, z, tmp) {332 result.assign(x);333 result.and(y);334 tmp.assign(x);335 tmp.not();336 tmp.and(z);337 result.xor(tmp);338 }339 function maj(result, x, y, z, tmp) {340 result.assign(x);341 result.and(y);342 tmp.assign(x);343 tmp.and(z);344 result.xor(tmp);345 tmp.assign(y);346 tmp.and(z);347 result.xor(tmp);348 }349 function sigma(result, x, tmp) {350 result.assign(x);351 result.rotateRight(28);352 tmp.assign(x);353 tmp.rotateRight(34);354 result.xor(tmp);355 tmp.assign(x);356 tmp.rotateRight(39);357 result.xor(tmp);358 }359 function sigmaPrime(result, x, tmp) {360 result.assign(x);361 result.rotateRight(14);362 tmp.assign(x);363 tmp.rotateRight(18);364 result.xor(tmp);365 tmp.assign(x);366 tmp.rotateRight(41);367 result.xor(tmp);368 }369 function littleSigma(result, x, tmp) {370 result.assign(x);371 result.rotateRight(1);372 tmp.assign(x);373 tmp.rotateRight(8);374 result.xor(tmp);375 tmp.assign(x);376 tmp.shiftRight(7);377 result.xor(tmp);378 }379 function littleSigmaPrime(result, x, tmp) {380 result.assign(x);381 result.rotateRight(19);382 tmp.assign(x);383 tmp.rotateRight(61);384 result.xor(tmp);385 tmp.assign(x);386 tmp.shiftRight(6);387 result.xor(tmp);388 }389 var k = [390 new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd),391 new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc),392 new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019),393 new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118),394 new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe),395 new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2),396 new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1),397 new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694),398 new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3),399 new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65),400 new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483),401 new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5),402 new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210),403 new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4),404 new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725),405 new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70),406 new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926),407 new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df),408 new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8),409 new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b),410 new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001),411 new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30),412 new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910),413 new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8),414 new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53),415 new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8),416 new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb),417 new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3),418 new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60),419 new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec),420 new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9),421 new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b),422 new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207),423 new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178),424 new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6),425 new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b),426 new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493),427 new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c),428 new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a),429 new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)];430 function hash(data, offset, length, mode384) {431 mode384 = !!mode384;432 // initial hash values433 var h0, h1, h2, h3, h4, h5, h6, h7;434 if (!mode384) {435 h0 = new Word64(0x6a09e667, 0xf3bcc908);436 h1 = new Word64(0xbb67ae85, 0x84caa73b);437 h2 = new Word64(0x3c6ef372, 0xfe94f82b);438 h3 = new Word64(0xa54ff53a, 0x5f1d36f1);439 h4 = new Word64(0x510e527f, 0xade682d1);440 h5 = new Word64(0x9b05688c, 0x2b3e6c1f);441 h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);442 h7 = new Word64(0x5be0cd19, 0x137e2179);443 }444 else {445 // SHA384 is exactly the same446 // except with different starting values and a trimmed result447 h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);448 h1 = new Word64(0x629a292a, 0x367cd507);449 h2 = new Word64(0x9159015a, 0x3070dd17);450 h3 = new Word64(0x152fecd8, 0xf70e5939);451 h4 = new Word64(0x67332667, 0xffc00b31);452 h5 = new Word64(0x8eb44a87, 0x68581511);453 h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);454 h7 = new Word64(0x47b5481d, 0xbefa4fa4);455 }456 // pre-processing457 var paddedLength = Math.ceil((length + 17) / 128) * 128;458 var padded = new Uint8Array(paddedLength);459 var i, j, n;460 for (i = 0; i < length; ++i) {461 padded[i] = data[offset++];462 }463 padded[i++] = 0x80;464 n = paddedLength - 16;465 while (i < n) {466 padded[i++] = 0;467 }468 padded[i++] = 0;469 padded[i++] = 0;470 padded[i++] = 0;471 padded[i++] = 0;472 padded[i++] = 0;473 padded[i++] = 0;474 padded[i++] = 0;475 padded[i++] = 0;476 padded[i++] = 0;477 padded[i++] = 0;478 padded[i++] = 0;479 padded[i++] = (length >>> 29) & 0xFF;480 padded[i++] = (length >> 21) & 0xFF;481 padded[i++] = (length >> 13) & 0xFF;482 padded[i++] = (length >> 5) & 0xFF;483 padded[i++] = (length << 3) & 0xFF;484 var w = new Array(80);485 for (i = 0; i < 80; i++) {486 w[i] = new Word64(0, 0);487 }488 var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);489 var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);490 var g = new Word64(0, 0), h = new Word64(0, 0);491 var t1 = new Word64(0, 0), t2 = new Word64(0, 0);492 var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;493 // for each 1024 bit block494 for (i = 0; i < paddedLength;) {495 for (j = 0; j < 16; ++j) {496 w[j].high = (padded[i] << 24) | (padded[i + 1] << 16) |497 (padded[i + 2] << 8) | (padded[i + 3]);498 w[j].low = (padded[i + 4]) << 24 | (padded[i + 5]) << 16 |499 (padded[i + 6]) << 8 | (padded[i + 7]);500 i += 8;501 }502 for (j = 16; j < 80; ++j) {503 tmp3 = w[j];504 littleSigmaPrime(tmp3, w[j - 2], tmp2);505 tmp3.add(w[j - 7]);506 littleSigma(tmp1, w[j - 15], tmp2);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptonum = require('wptonum').Word64;2var wptonum = require('wptonum').Word64;3var wptonum = require('wptonum').Word64;4var wptonum = require('wptonum').Word64;5var wptonum = require('wptonum').Word64;6var wptonum = require('wptonum').Word64;7var wptonum = require('wptonum').Word64;8var wptonum = require('wptonum').Word64;9var wptonum = require('wptonum').Word64;10var wptonum = require('wptonum').Word64;11var wptonum = require('wptonum').Word64;12var wptonum = require('wptonum').Word64;13var wptonum = require('wptonum').Word64;14var wptonum = require('wptonum').Word64;15var wptonum = require('wptonum').Word64;16var wptonum = require('wptonum').Word64;17var wptonum = require('wptonum').Word64;18var wptonum = require('wptonum').Word64;19var wptonum = require('wptonum').Word64;20var wptonum = require('wptonum').Word64;21var wptonum = require('wptonum').Word64;22var wptonum = require('wptonum').Word64;23var wptonum = require('wptonum').Word64;24var wptonum = require('wptonum').Word64;25var wptonum = require('wptonum').Word64;

Full Screen

Using AI Code Generation

copy

Full Screen

1var Word64 = require('word64');2var wptools = require('wptools');3var fs = require('fs');4var path = require('path');5var request = require('request');6var url = require('url');7var async = require('async');8var crypto = require('crypto');9var zlib = require('zlib');10var http = require('http');11var https = require('https');12var cluster = require('cluster');13var os = require('os');14var exec = require('child_process').exec;15var spawn = require('child_process').spawn;16var events = require('events');17var util = require('util');18var EventEmitter = require('events').EventEmitter;19var wptools = require('wptools');20var fs = require('fs');21var path = require('path');22var request = require('request');23var url = require('url');24var async = require('async');25var crypto = require('crypto');26var zlib = require('zlib');27var http = require('http');28var https = require('https');29var cluster = require('cluster');30var os = require('os');31var exec = require('child_process').exec;32var spawn = require('child_process').spawn;33var events = require('events');34var util = require('util');35var EventEmitter = require('events').EventEmitter;36var Word64 = require('word64');

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const page = wptools.page('Albert Einstein');3page.get()4 .then((page) => {5 console.log(page.infobox());6 })7 .catch((e) => {8 console.log(e);9 });10const wptools = require('wptools');11const page = wptools.page('Albert Einstein');12page.get()13 .then((page) => {14 console.log(page.infobox());15 })16 .catch((e) => {17 console.log(e);18 });19const wptools = require('wptools');20const page = wptools.page('Albert Einstein');21page.get()22 .then((page) => {23 console.log(page.infobox());24 })25 .catch((e) => {26 console.log(e);27 });28const wptools = require('wptools');29const page = wptools.page('Albert Einstein');30page.get()31 .then((page) => {32 console.log(page.infobox());33 })34 .catch((e) => {35 console.log(e);36 });37const wptools = require('wptools');38const page = wptools.page('Albert Einstein');39page.get()40 .then((page) => {41 console.log(page.infobox());42 })43 .catch((e) => {44 console.log(e);45 });46const wptools = require('wptools');47const page = wptools.page('Albert Einstein');48page.get()49 .then((page) => {50 console.log(page.infobox());51 })52 .catch((e) => {53 console.log(e);54 });55const wptools = require('wptools');56const page = wptools.page('Albert Einstein');57page.get()58 .then((page) => {59 console.log(page.infobox());60 })61 .catch((e) => {62 console.log(e);63 });

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 console.log(resp);5});6### wptools.page(title, options)7### page.get(callback)8### page.getCategories(callback)9### page.getImages(callback)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptool = require('wptool');2var word64 = new wptool.Word64(0x12345678, 0x9abcdef0);3console.log(word64.toString());4var wptool = require('wptool');5var word64 = new wptool.Word64(0x12345678, 0x9abcdef0);6console.log(word64.toString());7var wptool = require('wptool');8var word64 = new wptool.Word64(0x12345678, 0x9abcdef0);9console.log(word64.toString());10var wptool = require('wptool');11var word64 = new wptool.Word64(0x12345678, 0x9abcdef0);12console.log(word64.toString());13var wptool = require('wptool');14var word64 = new wptool.Word64(0x12345678, 0x9abcdef0);15console.log(word64.toString());16var wptool = require('wptool');17var word64 = new wptool.Word64(0x12345678, 0x9abcdef0);18console.log(word64.toString());19var wptool = require('wptool');20var word64 = new wptool.Word64(0x12345678, 0x9abcdef0);21console.log(word64.toString());22var wptool = require('wptool');

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