Guest User

Untitled

a guest
Jun 18th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. //Here is how you encode normal text to base64 in Node.js:
  2. var b = new Buffer('JavaScript');
  3. var s = b.toString('base64');
  4. // SmF2YVNjcmlwdA==
  5.  
  6. //And here is how you decode base64 encoded strings:
  7. var b = new Buffer('SmF2YVNjcmlwdA==', 'base64')
  8. var s = b.toString();
  9. // JavaScript
  10.  
  11.  
  12.  
  13. //Let's encode a base64 encoded string to hex:
  14. var b = new Buffer('SmF2YVNjcmlwdA==', 'base64')
  15. var s = b.toString('hex');
  16. // 4a617661536372697074
  17.  
  18. //Now decode it to something humans can read:
  19. var b = new Buffer('4a617661536372697074', 'hex')
  20. var s = b.toString('utf8');
  21. // JavaScript
Add Comment
Please, Sign In to add comment