Skip to content

Instantly share code, notes, and snippets.

@emilbayes
Last active November 7, 2016 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilbayes/f93cc288cca2458f76708874c6b1701f to your computer and use it in GitHub Desktop.
Save emilbayes/f93cc288cca2458f76708874c6b1701f to your computer and use it in GitHub Desktop.
Browserify Buffer bug?
$ browserify bug.js | browser-run
in U3iVZVfIGlCmd9SXTxb3YIclM2+vpRr+zUm2AbKrsT/p45H+hkFfB5SRX9cbLFso17Z5YsfonOPnf0xtuP/aPA==
out U3jvv71lV++/vRpQ77+9d9SXTxbvv71g77+9JTNv77+977+9Gu+/ve+/vUnvv70B77+977+977+9P++/ve+/vQ==
var TAG_LENGTH = 8
var buf = Buffer.from('U3iVZVfIGlCmd9SXTxb3YIclM2+vpRr+zUm2AbKrsT/p45H+hkFfB5SRX9cbLFso17Z5YsfonOPnf0xtuP/aPA==.ed25519')
console.log('from', buf.slice(0, buf.length - TAG_LENGTH).toString())
// Not being able to read part of the buffer in a specific encoding is weird
var secretKey = Buffer.alloc(64, buf.slice(0, buf.length - TAG_LENGTH).toString(), 'base64')
console.log('sk', secretKey.toString('base64'))
$ node bug.js
in U3iVZVfIGlCmd9SXTxb3YIclM2+vpRr+zUm2AbKrsT/p45H+hkFfB5SRX9cbLFso17Z5YsfonOPnf0xtuP/aPA==
out U3iVZVfIGlCmd9SXTxb3YIclM2+vpRr+zUm2AbKrsT/p45H+hkFfB5SRX9cbLFso17Z5YsfonOPnf0xtuP/aPA==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment