Skip to content

Instantly share code, notes, and snippets.

@alexcusack
Last active August 25, 2017 22:21
Show Gist options
  • Save alexcusack/c3e253d96abd2ba6780cf0ea42dbd82d to your computer and use it in GitHub Desktop.
Save alexcusack/c3e253d96abd2ba6780cf0ea42dbd82d to your computer and use it in GitHub Desktop.
// 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