Last active
August 25, 2017 22:21
-
-
Save alexcusack/c3e253d96abd2ba6780cf0ea42dbd82d 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
// hash a string to a 64bit Int | |
import { createHash } from 'crypto' | |
function stringToInt(lockName) { | |
const buf = createHash('sha256').update(lockName).digest() | |
return [buf.readInt32LE(0), buf.readInt32LE(4)] | |
} | |
// implementation credit: https://github.com/binded/advisory-lock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment