Guest User

Untitled

a guest
Apr 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. let encodeEmail = function(email) {
  2. let byteArray = [];
  3. for(i =0; i < email.length; i++) {
  4. byteArray.push(email.charCodeAt(i));
  5. }
  6. return encodeURIComponent(byteArray.toString());
  7. }
  8.  
  9. let decodeEmail = function(encodedEmail) {
  10. let byteArray = decodeURIComponent(encodedEmail).split(',');
  11. let email = String.fromCharCode(...byteArray);
  12.  
  13. return email;
  14. }
  15.  
  16.  
  17. let email = 'test.のコンサ@abc.com';
  18. console.log(encodeEmail(email)); //116%2C101%2C115%2C116%2C46%2C12398%2C12467%2C12531%2C12469%2C64%2C97%2C98%2C99%2C46%2C99%2C111%2C109​​​​​
  19. console.log(decodeEmail(encodeEmail(email))); //test.のコンサ@abc.com
Add Comment
Please, Sign In to add comment