These 2 functions are used to perform encryptions. They are currently
set up to perform triple des encrypting on information that will be
stored in a file. The str_replace calls at the beginning of each function
were put there after hours of debugging, i am sure the replacements could
be done quicker... These functions with a little modification could be used
to store encrypted information in a database... I prefer to use mcrypt over
any other encryption, because of the security.
_mencrypt ( string $input, string $key )
$input - stuff to encrypt
$key - the secret key to use
_mdecrypt ( string $input, string $key )
$input - stuff to decrypt
$key - the secret key to use
both function perform these:
substr(md5($key),0,24) - this make sure the secret key is the max
length, the longer the key the harder to
break it.
str_replace - a few characters , both function must be the same
Usage:
1. For storing Credit Card Numbers in a database.
2. encrypting a user file based on their password, their password would
be the key to decrypting. This also brings up a point that in this
user file could be used to stored other keys for decrypting other
sensitive data, such as credit card numbers.
These functions are currently running in an application for a hospital.
Any questions, or comments feel free to get in contact, i have received
allot from others, its time i gave back.
<?
//$input - stuff to encrypt
//$key - the secret key to use
dee artagnanh wrote :1822
As a PHP beginner, I find these functions useful. Is there
a bug here, though, as when I use '1234567' as input and
encrypt it, it can't decrypt it back right. Same happens
for any input string that starts with '12345678'
or '123456789'.