Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let encodeEmail = function(email) {
- let byteArray = [];
- for(i =0; i < email.length; i++) {
- byteArray.push(email.charCodeAt(i));
- }
- return encodeURIComponent(byteArray.toString());
- }
- let decodeEmail = function(encodedEmail) {
- let byteArray = decodeURIComponent(encodedEmail).split(',');
- let email = String.fromCharCode(...byteArray);
- return email;
- }
- let email = 'test.のコンサ@abc.com';
- console.log(encodeEmail(email)); //116%2C101%2C115%2C116%2C46%2C12398%2C12467%2C12531%2C12469%2C64%2C97%2C98%2C99%2C46%2C99%2C111%2C109
- console.log(decodeEmail(encodeEmail(email))); //test.のコンサ@abc.com
Add Comment
Please, Sign In to add comment