note 58446 modified in ref.mcrypt by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Dec 2010 16:24:14 +0000 |
| Subject: | note 58446 modified in ref.mcrypt by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174858@lists.php.net to get a copy of this message | ||
If you're going to encrypt data with something like this and store it in postgres.
<?php
function encrypt($string, $key){
$result = '';
for($i=1; $i<=strlen($string); $i++){
$char = substr($string, $i-1, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return $result;
}
?>
Make sure when you create your database to set the encoding to SQL_ASCII because you won't be
able to store this data in a database that uses UNICODE
--was--
If you're going to encrypt data with something like this and store it in postgres.
function encrypt($string, $key){
$result = '';
for($i=1; $i<=strlen($string); $i++){
$char = substr($string, $i-1, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return $result;
}
Make sure when you create your database to set the encoding to SQL_ASCII because you won't be
able to store this data in a database that uses UNICODE
http://php.net/manual/en/ref.mcrypt.php