หรือ
<?php
/**
* Eveyron PHP Library
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.opensource.org/licenses/bsd-license.php
*
* @category Eveyron
* @author [email protected]
* @copyright Copyright (c) 2010 eVeyron.com (http://www.eveyron.com)
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @link http://www.eveyron.com
* @version 2010-09-15 08:22:17Z
*/
/**
* Get EPD string from the GET variable
*
* @return string|null
*/
public static function getEpd()
{
if(array_key_exists('AP', $_GET)) {
return $_GET['AP'];
}
return null;
}
/**
* Decrypts a string using IPN security code and returns it as an array
*
* Modified version of the official EPD decrytpor class as found at
* http://dev.alertpay.com/en/resources/sdks-and-sample-codes/doc_download/11-epd-decryptor.html
*
* @param string $data encrypted data string
* @param string $key [optional] IPN security code
* @return array
* @throws Eveyron_Alertpay_Exception
*/
public static function decrypt($data, $key = null)
{
if(!extension_loaded('mcrypt')) {
throw new Eveyron_Alertpay_Exception('Mcrypt extension not available');
}
if($key === null) {
$key = self::$key;
}
if($key === null) {
throw new Eveyron_Alertpay_Exception('A key is required to decode data');
}
$data = base64_decode($data);
if($data === false) {
throw new Eveyron_Alertpay_Exception('Unable to base64_decode data');
}
$scode = '12345'; //the same code that using when create encrypted_text
$encrypted_text = 'unreadable text'; //encrypted text
$dct = new EPDDecryptor($scode);
echo $dct->decrypt($encrypted_text); //show readable text