當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mhash函數代碼示例

本文整理匯總了PHP中mhash函數的典型用法代碼示例。如果您正苦於以下問題:PHP mhash函數的具體用法?PHP mhash怎麽用?PHP mhash使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了mhash函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sha256

/**
 * Create a SHA256 hash of a string
 * 
 * Uses the PHP mhash library to create SHA256 hashes.  It's better than MD5 
 * and SHA1, and for small amounts of data isn't much slower.
 *
 * @param   string  $string     String to hash
 * @return  string  Hexadecimal representation of SHA256 hash
 */
function sha256($string)
{
    if (!function_exists('mhash')) {
        trigger_error('mhash not supported by this PHP installation');
    }
    return bin2hex(mhash(MHASH_SHA256, $string));
}
開發者ID:alanbriolat,項目名稱:CSF,代碼行數:16,代碼來源:csf_misc_functions.php

示例2: payment

 public function payment($data, $order_data, $auto_submit = false)
 {
     $data['order_id'] = $order_data['order_id'];
     if ($order_data['currency_id'] != 'USD') {
         throw new waPaymentException(_w('Order currency is not USD but payment gateway provide only USD transactions'));
     }
     $type_trans = array_flip(self::$type_trans);
     if (!empty($data['type']) && !empty($type_trans[$data['type']])) {
         $type = $type_trans[$data['type']];
     } else {
         $type = self::OPERATION_AUTH_ONLY;
     }
     if (empty($order_data['description_en'])) {
         $order_data['description_en'] = 'Order #' . $order_data['order_id'] . ' (' . gmdate('F, d Y') . ')';
     }
     $c = new waContact($order_data['contact_id']);
     $locale = $c->getLocale();
     $form_fields = array('x_login' => $this->login, 'x_amount' => number_format($order_data['amount'], 2, '.', ''), 'x_description' => $order_data['description_en'], 'x_invoice_num' => $order_data['order_id'], 'x_fp_sequence' => rand(1, 1000), 'x_fp_timestamp' => time(), 'x_test_request' => 'false', 'x_show_form' => 'PAYMENT_FORM', 'x_type' => $type, 'x_version' => '3.1', 'x_method' => 'CC', 'x_cust_id' => $order_data['contact_id'], 'x_customer_ip' => wa()->getRequest()->server('REMOTE_ADDR'), 'x_duplicate_window' => '28800', 'x_first_name' => waLocale::transliterate($c->get('firstname'), $locale), 'x_last_name' => waLocale::transliterate($c->get('lastname'), $locale), 'x_company' => waLocale::transliterate($c->get('company'), $locale), 'x_address' => waLocale::transliterate($c->get('address:street', 'default'), $locale), 'x_city' => waLocale::transliterate($c->get('address:city', 'default'), $locale), 'x_state' => waLocale::transliterate($c->get('address:region', 'default'), $locale), 'x_zip' => waLocale::transliterate($c->get('address:zip', 'default'), $locale), 'x_country' => waLocale::transliterate($c->get('address:country', 'default'), $locale), 'x_phone' => $c->get('phone', 'default'), 'x_email' => $c->get('email', 'default'), 'x_relay_response' => isset($data['x_relay_response']) ? $data['x_relay_response'] : 'true', 'x_relay_url' => $this->getRelayUrl(), 'wa_success_url' => $this->getAdapter()->getBackUrl(waAppPayment::URL_SUCCESS, $data), 'wa_decline_url' => $this->getAdapter()->getBackUrl(waAppPayment::URL_DECLINE, $data), 'wa_cancel_url' => $this->getAdapter()->getBackUrl(waAppPayment::URL_FAIL, $data), 'wa_app_id' => $this->app_id, 'wa_merchant_id' => $this->merchant_id);
     $form_fields['x_fp_hash'] = '';
     // @TODO: get from common 'address' field
     if (phpversion() >= '5.1.2') {
         $form_fields['x_fp_hash'] = hash_hmac('md5', $this->login . "^" . $form_fields['x_fp_sequence'] . "^" . $form_fields['x_fp_timestamp'] . "^" . $form_fields['x_amount'] . "^", $this->trans_key);
     } else {
         $form_fields['x_fp_hash'] = bin2hex(mhash(MHASH_MD5, $this->login . "^" . $form_fields['x_fp_sequence'] . "^" . $form_fields['x_fp_timestamp'] . "^" . $form_fields['x_amount'] . "^", $this->trans_key));
     }
     if ($this->form_header) {
         $form_fields['x_header_html_payment_form'] = $this->form_header;
     }
     $view = wa()->getView();
     $view->assign('url', wa()->getRootUrl());
     $view->assign('form_fields', $form_fields);
     $view->assign('form_url', $this->getEndpointUrl());
     $view->assign('auto_submit', $auto_submit);
     return $view->fetch($this->path . '/templates/payment.html');
 }
開發者ID:cjmaximal,項目名稱:webasyst-framework,代碼行數:35,代碼來源:authorizenetsimPayment.class.php

示例3: encrypt

 public function encrypt($data, $settings)
 {
     $cipher = $settings['cipher'] ?? 'sha256';
     $key = $settings['key'] ?? PROJECT_CONFIG['key'];
     $cipher = Converter::toConstant($cipher, 'MHASH_');
     return base64_encode(trim(mhash($cipher, $data, $key)));
 }
開發者ID:znframework,項目名稱:znframework,代碼行數:7,代碼來源:Mhash.php

示例4: generateRequestSign

 /**
  * Generates the fingerprint for request.
  *
  * @param string $merchantApiLoginId
  * @param string $merchantTransactionKey
  * @param string $amount
  * @param string $fpSequence An invoice number or random number.
  * @param string $fpTimestamp
  * @return string The fingerprint.
  */
 public function generateRequestSign($merchantApiLoginId, $merchantTransactionKey, $amount, $currencyCode, $fpSequence, $fpTimestamp)
 {
     if (phpversion() >= '5.1.2') {
         return hash_hmac("md5", $merchantApiLoginId . "^" . $fpSequence . "^" . $fpTimestamp . "^" . $amount . "^" . $currencyCode, $merchantTransactionKey);
     }
     return bin2hex(mhash(MHASH_MD5, $merchantApiLoginId . "^" . $fpSequence . "^" . $fpTimestamp . "^" . $amount . "^" . $currencyCode, $merchantTransactionKey));
 }
開發者ID:blazeriaz,項目名稱:youguess,代碼行數:17,代碼來源:Request.php

示例5: Cipher

 function Cipher($textkey)
 {
     $this->enc = MCRYPT_RIJNDAEL_128;
     $this->mode = MCRYPT_MODE_ECB;
     $this->securekey = mhash(MHASH_SHA256, $textkey);
     $iv_size = mcrypt_get_iv_size($this->enc, $this->mode);
     $this->iv = mcrypt_create_iv($iv_size, MCRYPT_DEV_RANDOM);
 }
開發者ID:billstclair,項目名稱:loomclient,代碼行數:8,代碼來源:Cipher.php

示例6: ComparePassword

function ComparePassword($password, $hash)
{
    $hash = base64_decode(substr($hash, 6));
    $original_hash = substr($hash, 0, 20);
    $salt = substr($hash, 20);
    $new_hash = mhash(MHASH_SHA1, $password . $salt);
    return strcmp($original_hash, $new_hash);
}
開發者ID:seyyah,項目名稱:f3ldap,代碼行數:8,代碼來源:ldap_fun.php

示例7: generatePrivateKey

 public static function generatePrivateKey($s, $size)
 {
     if (function_exists('mhash') && defined('MHASH_SHA256')) {
         return convertStringToByteArray(substr(mhash(MHASH_SHA256, $s), 0, $size));
     } else {
         throw new Exception('cryptoHelpers::generatePrivateKey currently requires mhash');
     }
 }
開發者ID:riddya85,項目名稱:rentail_upwrk,代碼行數:8,代碼來源:cryptoHelpers.php

示例8: validateHash

 /**
  * Проверка подписи платежа
  */
 public function validateHash($validator, $values)
 {
     $sign = base64_encode(mhash(MHASH_SHA1, sfConfig::get('app_sentry_password') . $values['MerID'] . $values['AcqID'] . $values['OrderID']));
     if ($sign === @$values['Signature']) {
         return $sign;
     }
     throw new sfValidatorError($validator, 'Invalid.');
 }
開發者ID:pycmam,項目名稱:myPaymentPlugin,代碼行數:11,代碼來源:SentryResultForm.class.php

示例9: encrypt

 public function encrypt($data = '', $settings = array())
 {
     $cipher = isset($settings['cipher']) ? $settings['cipher'] : 'sha256';
     $key = isset($settings['key']) ? $settings['key'] : Config::get('Encode', 'projectKey');
     // MHASH_ ön eki ilave ediliyor.
     $cipher = Convert::toConstant($cipher, 'MHASH_');
     return base64_encode(trim(mhash($cipher, $data, $key)));
 }
開發者ID:bytemtek,項目名稱:znframework,代碼行數:8,代碼來源:Mhash.php

示例10: extractTokenFromMetadata

 /**
  * @param Metadata $metadata metadata
  *
  * @return string
  */
 private function extractTokenFromMetadata(Metadata $metadata)
 {
     $phrase = $metadata->key;
     if ($metadata->passphrase) {
         $phrase .= ':' . $metadata->passphrase;
     }
     return mhash(MHASH_SHA256, $phrase);
 }
開發者ID:rezzza,項目名稱:vaultage,代碼行數:13,代碼來源:Cipher.php

示例11: make_md4_password

function make_md4_password($password)
{
    if (function_exists('hash')) {
        $hash = strtoupper(hash("md4", iconv("UTF-8", "UTF-16LE", $password)));
    } else {
        $hash = strtoupper(bin2hex(mhash(MHASH_MD4, iconv("UTF-8", "UTF-16LE", $password))));
    }
    return $hash;
}
開發者ID:acaranta,項目名稱:ldap-selfservice,代碼行數:9,代碼來源:functions.inc.php

示例12: punHash

 /**
  * old punbb hash function
  * @return string
  */
 public static function punHash($str)
 {
     if (function_exists('sha1')) {
         return sha1($str);
     } elseif (function_exists('mhash')) {
         return bin2hex(mhash(MHASH_SHA1, $str));
     }
     return md5($str);
 }
開發者ID:snouhaud,項目名稱:camptocamp.org,代碼行數:13,代碼來源:Punbb.class.php

示例13: createAuthToken

 public function createAuthToken()
 {
     $datePart = gmdate("Ymd");
     $timePart = gmdate("H");
     
     $authString = $this->securityWord . ":" . $datePart . ":" . $timePart;
     $sha256     = bin2hex(mhash(MHASH_SHA256, $authString));
     return strtoupper($sha256);
 }
開發者ID:hungnv0789,項目名稱:vhtm,代碼行數:9,代碼來源:apiagent.php

示例14: _digestMhash

 protected static function _digestMhash($algorithm, $data, $binaryOutput)
 {
     $constant = constant('MHASH_' . strtoupper($algorithm));
     $binary = mhash($constant, $data);
     if ($binaryOutput) {
         return $binary;
     }
     return bin2hex($binary);
 }
開發者ID:kaseya-university,項目名稱:efront,代碼行數:9,代碼來源:Crypt.php

示例15: create_form

 /**
  * 新增
  */
 function create_form($list)
 {
     $pname = get_class($this);
     $this_script = "http://{$_SERVER['HTTP_HOST']}";
     $this->add_field('v_mid', GetValue($pname . "_id"));
     //商戶編號
     $this->add_field('v_oid', date('Ymd') . '-' . GetValue($pname . "_id") . '-' . $list['sn']);
     //訂單編號
     $this->add_field('v_rcvname', $list['delivery_firstname'] . " " . $list['delivery_lastname']);
     //收貨人姓名
     $this->add_field('v_rcvaddr', $list['delivery_address']);
     //收貨人地址
     $this->add_field('v_rcvtel', $list['delivery_telephone']);
     //收貨人電話
     $this->add_field('v_rcvpost', $list['delivery_zip']);
     //收貨人郵編
     $this->add_field('v_amount', $list['orders_total']);
     //訂單總金額
     //$this->add_field('v_language','en');//訂單語言
     $this->add_field('v_ymd', date('Ymd', $list['dateline']));
     //訂單產生日期
     $this->add_field('v_orderstatus', 1);
     //配貨狀態
     $this->add_field('v_ordername', $list['delivery_firstname'] . " " . $list['delivery_lastname']);
     //訂貨人姓名
     $this->add_field('v_moneytype', 1);
     //幣種,0為人民幣,1為美元,2為歐元,3為英鎊,4為日元,5為韓元,6為澳大利亞元
     $this->add_field('v_url', $this_script . U('Payment/payeasy_return'));
     //支付動作完成後返回到該url,支付結果以GET方式發送
     $this->add_field('v_md5info', bin2hex(mhash(MHASH_MD5, "1" . date('Ymd', $list['dateline']) . $list['orders_total'] . $list['delivery_firstname'] . " " . $list['delivery_lastname'] . date('Ymd') . '-' . GetValue($pname . "_id") . '-' . $list['sn'] . GetValue($pname . "_id") . $this_script . U('Payment/payeasy_return'), GetValue($pname . "_key"))));
     //訂單數字指紋
     $this->add_field('v_shipstreet', $list['delivery_address']);
     //送貨街道地址
     $this->add_field('v_shipcity', $list['delivery_city']);
     //送貨城市
     //$this->add_field('v_shipstate',$_POST['']);//送貨省/州
     $this->add_field('v_shippost', $list['delivery_zip']);
     //送貨郵編
     //$this->add_field('v_shipcountry','840');//送貨國家
     $this->add_field('v_shipphone', $list['delivery_telephone']);
     //送貨電話
     $this->add_field('v_shipemail', $list['delivery_email']);
     //送貨Email
     $this->form .= "<form method=\"post\" name=\"pay_form\" ";
     $this->form .= "action=\"" . $this->submit_url . "\">\n";
     foreach ($this->fields as $name => $value) {
         $this->form .= "<input type=\"hidden\" name=\"{$name}\" value=\"{$value}\"/>\n";
     }
     $this->form .= "</form>\n";
     if (GetValue($list['payment_module_code'] . '_autosubmit') == 1) {
         $delay = GetValue($list['payment_module_code'] . '_delay');
         $delay = $delay ? $delay : 5;
         $this->form .= $this->submit($delay);
         //是否自動提交,延遲5秒
     }
     return $this->form;
 }
開發者ID:anshidai,項目名稱:bagsloves,代碼行數:60,代碼來源:payeasy3d.class.php


注:本文中的mhash函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。