Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Here is how you encode normal text to base64 in Node.js:
- var b = new Buffer('JavaScript');
- var s = b.toString('base64');
- // SmF2YVNjcmlwdA==
- //And here is how you decode base64 encoded strings:
- var b = new Buffer('SmF2YVNjcmlwdA==', 'base64')
- var s = b.toString();
- // JavaScript
- //Let's encode a base64 encoded string to hex:
- var b = new Buffer('SmF2YVNjcmlwdA==', 'base64')
- var s = b.toString('hex');
- // 4a617661536372697074
- //Now decode it to something humans can read:
- var b = new Buffer('4a617661536372697074', 'hex')
- var s = b.toString('utf8');
- // JavaScript
Add Comment
Please, Sign In to add comment