Guest User

Untitled

a guest
Oct 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. // Add IE11 support
  2. const crypto = window.crypto || window.msCrypto
  3.  
  4. const generatePassword = (length = 10) => {
  5. const buffer = new Uint8Array(12)
  6. crypto.getRandomValues(buffer)
  7. return btoa(String.fromCharCode.apply(null, buffer)).substr(0, length)
  8. }
  9.  
  10. export default generatePassword
Add Comment
Please, Sign In to add comment