Sunday, April 22, 2012

Get value by tag name from the XML result using PHP


        /**
* A simple process to retrive XML data
*/
function get_value_by_tag_Name( $str, $s_tag, $e_tag)
{
$s = strpos( $str,$s_tag) + strlen( $s_tag);
$e = strlen( $str);
$str= substr($str, $s, $e);
$e = strpos( $str,$e_tag);
$str= substr($str,0, $e);
$str= substr($str,0, $e);
return  $str;
}




Credits
http://reazulk.wordpress.com

Friday, April 20, 2012

PHP Encrypt and Decrypt function


/*you can chage the key as your wish*/
$key = "+OmENio4F8/8895tSQXaS13hire3FjXAQ5EfRfgHseI=";

function encrypt( $string )
{
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
}

function decrypt( $encrypt_string )
{
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypt_string), MCRYPT_MODE_CBC, md5(md5($key))));
}

$srt ='malinda';
$en = encrypt( $srt );
$de = decrypt( $en );

echo "String - " . $srt.'<br/>';

echo "Encrypt String - " . $en.'<br/>';

echo "Decrypt String - " . $de.'<br/>';


Credits -  http://ideone.com/yQIAX