Skip to content

Instantly share code, notes, and snippets.

@emilbayes emilbayes/browser.sh Secret
Last active Nov 7, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.