Hope you like this tutorial, I will be happy to see you in comment section below. Similarly str_repeat() repeats the given string.įinally I collected all strings on $hide_email and return it. Generate random index from 0 to string length-1. It can be achieved as follows: Store all the possible letters into a string. APPROACH 1: Brute Force The first approach is the simplest one to understand and thus brute force. Substr() will remove all character after given second parameter in the string. Generate a random, unique, alpha-numeric string using PHP. Str_replace() will replace first parameter with second parameter in third parameter. Strlen() function returns length of string. The first part of email is before sign and second part of email is after sign. Lets do it, First we will verify email is valid or not then we replace each except first two character with '*'.Īt first we validate email with PHP's pre-loaded function filter_var and FILTER_VALIDATE_EMAILĪfter that I broke email into array with explode function. Freely use the email generator to create randomly an anonymous email address and hide your email. For example, to generate a random float between 0 and 1, you could use. It will display just few character of email address and email domain. In PHP, you can generate a random float by dividing a random integer by the maximum value of the random number generator. In this tutorial I will show step by step method to hide email address partially. If you want to do same in your PHP web application then this post is for you. To reduce risk of user enumeration vulnerability. Perhaps you may noticed twitter, facebook, google partially hide email address during forgot password process.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |