/**
  * Подпись запроса
  */
 protected function createSign(array $data)
 {
     function hexbin($temp)
     {
         $data = "";
         $len = strlen($temp);
         for ($i = 0; $i < $len; $i += 2) {
             $data .= chr(hexdec(substr($temp, $i, 2)));
         }
         return $data;
     }
     $sign = base64_encode(hexbin(sha1(sfConfig::get('app_sentry_password') . $data['MerID'] . $data['AcqID'] . $data['OrderID'] . $data['PurchaseAmt'] . $data['PurchaseCurrency'])));
     return $sign;
 }
// WTF IS HEXADECIMAL REPRESENTATION IF IT DOESN'T CONVERT TO REAL HEX?
// F**k?!
// Converts binary to ( --> hexadecimal representation  <-- )
echo bin2hex(11111111) . PHP_EOL;
// 3131313131313131
/*
  This function is for converting binary data into a hexadecimal string representation.
  This function is not for converting strings representing binary digits into hexadecimal.
  If you want that functionality, you can simply do this:
*/
$binary = "11111111";
$hex = dechex(bindec($binary));
echo $hex . PHP_EOL;
// Another example from php.net:
// -------------------------------------------------------------------------------------------
// I thought it'll give me an "F" if i give it a "1111"...
// Here's something to convert a binary-string into a hex-string and other direction too:
function hexbin($hex)
{
    $bin = decbin(hexdec($hex));
    return $bin;
}
function binhex($bin)
{
    $hex = dechex(bindec($bin));
    return $hex;
}
echo hexbin('F') . PHP_EOL;
// 1111
echo binhex('1111') . PHP_EOL;
// f
Exemple #3
0
                                $amount = preg_replace("/\\./ui", "", $money_privatbank);
                                while (strlen($amount) < 12) {
                                    $amount = "0" . $amount;
                                }
                                $money_privatbank_usd = sprintf("%01.2f", $money_privatbank_usd);
                                $amount_usd = preg_replace("/\\./ui", "", $money_privatbank_usd);
                                while (strlen($amount_usd) < 12) {
                                    $amount_usd = "0" . $amount_usd;
                                }
                                if ($PRIVATBANK_TEST) {
                                    $orderID = "Test_" . $privatbank_name . "_" . time() . "_{$r->id}";
                                } else {
                                    $orderID = time() . "_" . $r->id;
                                }
                                $hash = sha1($privatbank_pass . $privatbank_id . "414963" . $orderID . $amount . "980" . $amount_usd . "840" . $desc);
                                $hash = hexbin($hash);
                                $hash = base64_encode($hash);
                                #						$path = preg_replace("/http:/ui","https:",$full_www_path);
                                ?>

			                        <form target=_blank method="POST" style="margin: 0;" action="https://ecommerce.liqpay.com/ecommerce/CheckOutPagen">
						<input type='hidden' value='1.0.0' name='Version'>
						<input type='hidden' value='414963' name='acqid'>
						<input type='hidden' value='<?php 
                                print $privatbank_id;
                                ?>
' name='merid'>
						<input type='hidden' value='<?php 
                                print $orderID;
                                ?>
' name='orderid'>
Exemple #4
0
function init($string)
{
    $len = strlen($string) * 8;
    $hex = strhex($string);
    // convert ascii string to hex
    $bin = leftpad(hexbin($hex), $len);
    // convert hex string to bin
    $padded = pad($bin);
    $padded = pad($padded, 1, $len);
    $block = str_split($padded, 32);
    foreach ($block as &$b) {
        $b = implode('', array_reverse(str_split($b, 8)));
    }
    return $block;
}