Last active
December 14, 2016 16:25
-
-
Save danielo515/c10b7cf8725020a9ffbd83666021b55a to your computer and use it in GitHub Desktop.
A small benchmark to check if Crypto JS is able to generate GUUID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CryptoJS = require("crypto-js"); | |
const _ = require('lodash'); | |
let i = 5000; | |
const keys = []; | |
console.time('Generating keys'); | |
while(--i) | |
keys.push(CryptoJS.lib.WordArray.random(128 / 8).toString(CryptoJS.sha256)); | |
i = 5000 | |
while(--i) | |
keys.push(CryptoJS.lib.WordArray.random(128 / 8).toString(CryptoJS.sha256)); | |
console.timeEnd('Generating keys'); | |
console.log(keys) | |
console.time('Checking dups'); | |
const dups = _.filter(keys, (value, index, iteratee) => _.includes(iteratee, value, index + 1)) | |
console.timeEnd('Checking dups'); | |
console.log(dups) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment