Sometimes, we want to obfuscate an e-mail address on a website with JavaScript.
In this article, we’ll look at how to obfuscate an e-mail address on a website with JavaScript.
How to obfuscate an e-mail address on a website with JavaScript?
To obfuscate an e-mail address on a website with JavaScript, we can use the btoa
function.
For instance, we write
const obfuscatedEmail = btoa("mailto:email@example.com");
to call btoa
with the email URL string to base64 encode the string.
This will obfuscate the string from users.
Then we can call atob
with the obfuscated string to decode it back to the original URL.
Conclusion
To obfuscate an e-mail address on a website with JavaScript, we can use the btoa
function.