| Autor |
Mesaj |
Xen0n
Administrator *eG*


Data inscrierii: 21/Ian/2009 Mesaje: 184 Localitate: Satu Mare |
|
Email Encryption Against Spam, Plus Ways To Prevent It |
|
Lets start off by creating a simply php function called encryptEmail(), and we will supply this function with two arguments. $email which is the email address we are encrypting, and $at which will be the returned separator of the email (@ sign).
// Encrypts an email making it spam proof against bots
function encryptEmail($email, $at="@") {
$value = "";
}
Next we will have to făurite a for loop, that will search through each letter of the email address.
// Encrypts an email making it spam proof against bots
function encryptEmail($email, $at="@") {
$value = "";
// Give letters their ASCII value
for ($i = 0; $i < strlen($email); $i++) {
$letter = substr($email, $i, 1);
}
}
We will now add the most important part of this loop, the ord() function. This ord() function returns the ASCII value of each letter or number, allowing the letters to be encrypted using ASCII instead of plain text. This also separates the email into 3 parts; $email which is the individuals email account, $at which is the at separator between the email and the domain, and $domain which is the domain the email is hosted at.
// Encrypts an email making it spam proof against bots
function encryptEmail($email, $at="@") {
$value = "";
// Give letters their ASCII value
for ($i = 0; $i < strlen($email); $i++) {
$letter = substr($email, $i, 1);
if ($letter == "@") {
$account = $value;
$value = "";
} else {
$value .= "&#" . ord($letter) . ";";
}
}
}
Now we shall combine the three variables, and return the encrypted email address. And Wala! there you have it, a simple way to encrypt your email address. Also here is an example of how to call this script.
// Encrypts an email making it spam proof against bots
function encryptEmail($email, $at="@") {
$value = "";
// Give letters their ASCII value
for ($i = 0; $i < strlen($email); $i++) {
$letter = substr($email, $i, 1);
if ($letter == "@") {
$account = $value;
$value = "";
} else {
$value .= "&#" . ord($letter) . ";";
}
}
// Return encrypted email address
$domain = $value;
$encrypted = $account . $at . $domain;
return $encrypted;
}
// Using the function
// Echos: email[[at]]domain.com
// Encrypted: email[[at]]domain.com
echo encryptEmail("email@domain.com", "[[at]]");
|
|
| 07/03/2009 23:41 |
|
 |
|
|
Nu puteti crea un subiect nou in acest forum Nu puteti raspunde in subiectele acestui forum Nu puteti modifica mesajele proprii din acest forum Nu puteti sterge mesajele proprii din acest forum Nu puteti vota in chestionarele din acest forum
|
Powered by phpBB © 2001, 2005 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|
|