Last active
April 13, 2022 02:42
-
-
Save oshinko/38b3ebe4a1e5b453234ae7226bd35b22 to your computer and use it in GitHub Desktop.
Hash the date
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
d = new Date() | |
s = [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('/') | |
(async function(text, n) { | |
data = new TextEncoder().encode(text) | |
hash = await window.crypto.subtle.digest('SHA-1', data) | |
uint = new DataView(hash, 0).getUint32() | |
console.log(text, uint % n) | |
})(s, 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment