Mar
30
30
Encode and Decode using PHP
List of PHP functions:
sha1(), strlen(), ord(), substr(), strrev(), base_convert(), dechex(), hexdec() and chr()
Example of encode and decode using PHP
<?php
function encode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($x = 0; $x < $strLen; $x++) {
$ordStr = ord(substr($string,$x,1));
if ($y == $keyLen) { $y = 0; }
$ordKey = ord(substr($key,$y,1));
$y++;
$hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
}
...
Read more...
sha1(), strlen(), ord(), substr(), strrev(), base_convert(), dechex(), hexdec() and chr()
Example of encode and decode using PHP
<?php
function encode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($x = 0; $x < $strLen; $x++) {
$ordStr = ord(substr($string,$x,1));
if ($y == $keyLen) { $y = 0; }
$ordKey = ord(substr($key,$y,1));
$y++;
$hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
}
...
Read more...
March 30, 2011 | Add Comment
Mar
21
21
Connect MySQL using PHP
List of PHP functions:
defined(), define(), require_once(), mysql_connect(), mysql_select_db(), mysql_query(), mysql_fetch_array(), mysql_close(), mysql_error(), isset(), unset() and die()
First create a config file for database contants. Save this as config.php.
<?php
// Database Constants
defined('DB_SERVER') ? null : define("DB_SERVER", "localhost");
defined('DB_USER') ? null : define("DB_USER", "root");
defined('DB_PASS') ? null : define("DB_PASS", "pass");
defined('DB_NAME') ? null : define("DB_NAME", "mydatabase");
?>
The next step is to create...
Read more...
defined(), define(), require_once(), mysql_connect(), mysql_select_db(), mysql_query(), mysql_fetch_array(), mysql_close(), mysql_error(), isset(), unset() and die()
First create a config file for database contants. Save this as config.php.
<?php
// Database Constants
defined('DB_SERVER') ? null : define("DB_SERVER", "localhost");
defined('DB_USER') ? null : define("DB_USER", "root");
defined('DB_PASS') ? null : define("DB_PASS", "pass");
defined('DB_NAME') ? null : define("DB_NAME", "mydatabase");
?>
The next step is to create...
Read more...
March 21, 2011 | Add Comment







Contact Me!

Ubuntu 13.04 countdown
Latest Blog Post