Last active
April 27, 2020 16:31
-
-
Save jpehman/71fda39ab18f7d0fff29 to your computer and use it in GitHub Desktop.
This file contains 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
(function () { | |
var charArray = "ABCDEFGHI~`!@JKLMNOPQRSTUVWXYZ#$%^abcdefghijklm&*()nopqrstuvwxyz-_=+1234567890{[}]|:;',.<>?/".split(""); | |
var crypto = window.crypto || window.msCrypto; | |
if (!crypto.subtle) { | |
console.log("crypto not supported"); | |
return; | |
} | |
function getSalt (strLength) { | |
strLength = strLength || 64; | |
var array = new Uint8Array(strLength), salt = "", | |
arrLength, i = 0; | |
crypto.getRandomValues(array); | |
arrLength = array.length; | |
while (i < arrLength) { | |
salt += charArray[((new Date()).getTime() + array[i]) % 92]; | |
i += 1; | |
} | |
return salt; | |
} | |
window.getSalt = getSalt; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment