• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP hex2bin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中hex2bin函数的典型用法代码示例。如果您正苦于以下问题:PHP hex2bin函数的具体用法?PHP hex2bin怎么用?PHP hex2bin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了hex2bin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: prevChar

function prevChar($c)
{
    $car = bin2hex($c);
    $car = hexdec($car) - 1;
    $car = dechex($car);
    return hex2bin($car);
}
开发者ID:hesselek,项目名称:modulo_integrated,代码行数:7,代码来源:cripto.php


示例2: get_replay_type

function get_replay_type($data, $fileExtension)
{
    if (strcasecmp($fileExtension, "cnc4replay") == 0) {
        return "cnc4replay";
    }
    if (strcasecmp($fileExtension, "ra3replay") == 0) {
        return "ra3replay";
    }
    if (strcasecmp($fileExtension, "kwreplay") == 0) {
        return "kwreplay";
    }
    if (strcasecmp($fileExtension, "cnc3replay") == 0) {
        return "cnc3replay";
    }
    if (strcasecmp($fileExtension, "rep") == 0) {
        return "rep";
    }
    if (strcasecmp($fileExtension, "rec") == 0) {
        $hexdata = bin2hex($data);
        //先判断是否英雄连,第五个字节后为coh
        $cohToken = substr($hexdata, 8, 6);
        $cohToken = hex2bin($cohToken);
        if ($cohToken == "COH") {
            return "rec";
        }
        //是英雄连
        $dowToken = substr($hexdata, 24, 8);
        $dowToken = hex2bin($dowToken);
        if ($dowToken == "DOW2") {
            return "dow2";
        }
    }
}
开发者ID:istobran,项目名称:gt-replay-tool,代码行数:33,代码来源:tool.func.php


示例3: testCompatibility

 public function testCompatibility()
 {
     $h = hex2bin('cfceb8891c58071deedbd1');
     $k = 'key123';
     $p = 'hello world';
     $this->assertEquals($p, Otp::crypt($h, $k));
 }
开发者ID:dopecode,项目名称:dcrypt,代码行数:7,代码来源:OtpTest.php


示例4: mta_decode

function mta_decode($headers, $data)
{
    $encode_types = get_content_encoding($headers);
    $types = explode(',', $encode_types);
    $res_data = $data;
    foreach ($types as $type) {
        if ($type == 'rc4') {
            $res_data = mta_rc4($res_data);
        } else {
            if ($type == 'gzip') {
                $header = unpack('Nlength/Lgzip', $res_data);
                if (intval($header['gzip']) === 0x88b1f) {
                    $header = unpack('Nlength/H*body', $res_data);
                    //$header['ori_buf'] = bin2hex($res_data);
                    //$header['ori_len'] = strlen($res_data);
                    $res_data = hex2bin($header['body']);
                } else {
                }
                $res_data = gzdecode($res_data);
                //jsondb_logger('nofity', 'gzip log', ['res'=>$res_data,'len'=>strlen($res_data),'header'=>$header]);
            }
        }
    }
    if (empty($res_data)) {
        jsondb_logger('notify', 'error ' . bin2hex($data));
    }
    return json_decode($res_data);
}
开发者ID:sdgdsffdsfff,项目名称:client-ident-proxy,代码行数:28,代码来源:mta.php


示例5: decrypt

 /**
  * Decrypt the given value.
  *
  * @param string $value
  * 
  * @return string
  */
 private function decrypt($value)
 {
     if ($this->cipher) {
         return $this->cipher->decrypt(hex2bin($value));
     }
     return $value;
 }
开发者ID:snapshotpl,项目名称:psr7-middlewares,代码行数:14,代码来源:CryptTrait.php


示例6: testOurSubstrTrailingEmptyStringBugWeird

 public function testOurSubstrTrailingEmptyStringBugWeird()
 {
     $str = hex2bin('4d8ab774261977e13049c42b4996f2c4');
     $this->assertSame(16, Core::ourStrlen($str));
     if (ini_get('mbstring.func_overload') == 7) {
         // This checks that the above hex string is indeed "weird."
         // Edit: Er... at least, on PHP 5.6.0 and above it's weird.
         //  I DON'T KNOW WHY THE LENGTH OF A STRING DEPENDS ON THE VERSION
         //  OF PHP BUT APPARENTLY IT DOES ¯\_(ツ)_/¯
         if (version_compare(phpversion(), '5.6.0', '>=')) {
             $this->assertSame(12, strlen($str));
         } else {
             $this->assertSame(16, strlen($str));
         }
     } else {
         $this->assertSame(16, strlen($str));
         // We want ourSubstr to behave identically to substr() in PHP 7 in
         // the non-mbstring case. This double checks what that behavior is.
         if (version_compare(phpversion(), '7.0.0', '>=')) {
             $this->assertSame('', substr('ABC', 3, 0));
             $this->assertSame('', substr('ABC', 3));
         } else {
             // The behavior was changed for PHP 7. It used to be...
             $this->assertSame(false, substr('ABC', 3, 0));
             $this->assertSame(false, substr('ABC', 3));
         }
         // Seriously, fuck this shit. Don't use PHP. ╯‵Д′)╯彡┻━┻
     }
     // This checks that the behavior is indeed the same.
     $this->assertSame('', Core::ourSubstr($str, 16));
 }
开发者ID:twistor,项目名称:php-encryption,代码行数:31,代码来源:CoreTest.php


示例7: tagrm_post

function tagrm_post(&$a)
{
    if (!local_user()) {
        goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    }
    if (x($_POST, 'submit') && $_POST['submit'] === t('Cancel')) {
        goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    }
    $tag = x($_POST, 'tag') ? hex2bin(notags(trim($_POST['tag']))) : '';
    $item = x($_POST, 'item') ? intval($_POST['item']) : 0;
    $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_user()));
    if (!count($r)) {
        goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    }
    $arr = explode(',', $r[0]['tag']);
    for ($x = 0; $x < count($arr); $x++) {
        if ($arr[$x] === $tag) {
            unset($arr[$x]);
            break;
        }
    }
    $tag_str = implode(',', $arr);
    q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($tag_str), intval($item), intval(local_user()));
    info(t('Tag removed') . EOL);
    goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
    // NOTREACHED
}
开发者ID:nextgensh,项目名称:friendica,代码行数:27,代码来源:tagrm.php


示例8: get_peers_blocking

 private function get_peers_blocking($info_hash, $host = "router.bittorrent.com", $port = 6881)
 {
     //create a UDP socket to send commands through
     $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     //Create Command Packet
     $packet = bencode::encode(array("id" => $this->get_unique_node_id(), "info_hash" => hex2bin($info_hash)), array("q" => "get_peers", "t" => $this->unique_id(), "y" => "q"));
     socket_sendto($socket, $packet, strlen($packet), 0, $host, $port);
     //set timeout
     $timeout = array('sec' => 5, 'usec' => 0);
     socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $timeout);
     $time = time();
     //recieve data
     try {
         socket_recvfrom($socket, $buf, 12000, 0, $host, $port);
     } catch (Exception $e) {
         echo "Error";
         return FALSE;
     }
     //have to manually do the timeout, cant seem to get info from this socket
     if (time() - $time >= 4) {
         socket_close($socket);
         return FALSE;
     }
     //close socket so bad shit don't happen
     socket_close($socket);
     return nodeExtract::return_nodes(bencode::decode($buf));
 }
开发者ID:sharayuS,项目名称:PHP-K-DHT,代码行数:27,代码来源:dht.class.php


示例9: hexToBin

 /**
  * Hex to bin.
  *
  * @param string $value hex string
  * @return string
  */
 public static function hexToBin($value)
 {
     if (function_exists('hex2bin')) {
         return hex2bin($value);
     }
     return pack("H*", $value);
 }
开发者ID:romeoz,项目名称:rock-helpers,代码行数:13,代码来源:NumericHelper.php


示例10: testPBKDF2

 /**
  * @covers \Sarciszewski\PHPFuture\Security::pbkdf2()
  * ref https://www.ietf.org/rfc/rfc6070.txt
  */
 public function testPBKDF2()
 {
     $a = Future\Security::pbkdf2("sha1", "password", "salt", 2, 20, true);
     $this->assertEquals($a, hex2bin('ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957'));
     $b = Future\Security::pbkdf2("sha1", "password", "salt", 2, 20, false);
     $this->assertEquals($b, 'ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957');
 }
开发者ID:resonantcore,项目名称:php-future,代码行数:11,代码来源:Security.php


示例11: hexToBin

 /**
  * Custom implementation of hex2bin since the function is only available starting
  * with PHP 5.4
  *
  * @TODO Remove this once 5.3 support for ownCloud is dropped
  * @param $message
  * @return string
  */
 protected static function hexToBin($message)
 {
     if (function_exists('hex2bin')) {
         return hex2bin($message);
     }
     return pack("H*", $message);
 }
开发者ID:Combustible,项目名称:core,代码行数:15,代码来源:crypto.php


示例12: decode_password

/**
 * decode_password - decode encoded password to ascii string
 * @RA: Request Authenticator passed in from the Access Point
 * @encoded: The encoded password
 * @secret: Shared secret between node and server
 *
 * Returns decoded password or FALSE on error
 */
function decode_password($RA, $encoded, $secret)
{
    if (strlen($RA) != 32) {
        return FALSE;
    }
    $ra = hex2bin($RA);
    if ($ra === FALSE) {
        return FALSE;
    }
    if (strlen($encoded) % 32 != 0) {
        return FALSE;
    }
    $bincoded = hex2bin($encoded);
    $password = "";
    $last_result = $ra;
    for ($i = 0; $i < strlen($bincoded); $i += 16) {
        $key = hash('md5', $secret . $last_result, TRUE);
        for ($j = 0; $j < 16; $j++) {
            $password .= $key[$j] ^ $bincoded[$i + $j];
        }
        $last_result = substr($bincoded, $i, 16);
    }
    $j = 0;
    for ($i = strlen($password); $i > 0; $i--) {
        if ($password[$i - 1] != "") {
            break;
        } else {
            $j++;
        }
    }
    if ($j > 0) {
        $password = substr($password, 0, strlen($password) - $j);
    }
    return $password;
}
开发者ID:ozrouter,项目名称:docs,代码行数:43,代码来源:decode_password.php


示例13: downloadAction

 public function downloadAction($name = null)
 {
     $this->load->helper('download');
     $name = hex2bin($name);
     $array = $this->_get($name, true);
     force_download($name . '.php', $array, true);
 }
开发者ID:ProjectOrangeBox,项目名称:export_config,代码行数:7,代码来源:Export_configController.php


示例14: decryptPassword

function decryptPassword($input)
{
    $config = $GLOBALS['config'];
    if ($config['rsa_modulus'] != '' && $config['rsa_exponent'] != '' && $config['rsa_key'] != '' && isset($_SESSION['crypt_key'])) {
        if (substr($input, 0, 5) == "enc: ") {
            $input = substr($input, 5);
            $res = openssl_pkey_get_private($config['rsa_key'], $config['rsa_passphrase']);
            openssl_private_decrypt(hex2bin($input), $plaintext, $res);
            $plaintext = utf8_encode($plaintext);
            //loop through current session login keys and try all of them that haven't expired
            foreach ($_SESSION['crypt_key'] as $arrayKey => $key_array) {
                //key_array is array(time key was generated, hexadecimal key)
                if (time() - $key_array[0] > 5 * 60) {
                    //delete keys older than 5 minutes
                    //shouldn't take that long to login anyway!
                    unset($_SESSION['crypt_key'][$arrayKey]);
                } else {
                    $crypt_key = $key_array[1];
                    //first part of plaintext should be equal to crypt key
                    if (substr($plaintext, 0, strlen($crypt_key)) == $crypt_key) {
                        return substr($plaintext, strlen($crypt_key));
                    }
                }
            }
            //none of the keys above worked, either forgery or expired form
            return "";
        } else {
            return $input;
        }
    } else {
        return $input;
    }
}
开发者ID:uakfdotb,项目名称:oneapp,代码行数:33,代码来源:crypto.php


示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->prepareExecute($input, $output, $this);
     $this->connectMultichain();
     $this->multichainDebug($output);
     $this->connectMysql();
     $documentPath = $input->getArgument("document");
     $content = file_get_contents($documentPath);
     $hash = hash('sha256', $content);
     /** @var Document $ormDocument */
     $ormDocument = $this->em->getRepository('Multichain\\Console\\Entity\\Document')->findOneByContent($content);
     if ($ormDocument) {
         $hex = $ormDocument->getHex();
         $transaction = $this->multichain->getRawTransaction($hex, 1);
         $data = $transaction["data"][0];
         $parsedData = json_decode(hex2bin($data), true);
         $originalHash = $parsedData["hash"];
         $this->io->text("Submitted document has a hash of <fg=blue>" . $hash . "</fg=blue>");
         $this->io->text("Found document the same content in the MySQL database");
         if ($hash == $originalHash) {
             $this->io->text("Validated the hash found in the database with the Blockchain");
             $this->io->success('Hashes match! ' . $documentPath . ' is validated by the Blockchain');
         } else {
             $this->io->text("Unable to validated the hash found in the database with the Blockchain");
             $this->io->error('Hashes do not match! ' . $documentPath . ' is NOT validated by the Blockchain');
         }
     } else {
         $this->io->text("Submitted document has a hash of <fg=blue>" . $hash . "</fg=blue>");
         $this->io->text("Found no document with the same content.");
         $this->io->error('Hashes do not match! ' . $documentPath . ' is NOT validated by the Blockchain');
     }
 }
开发者ID:Kunstmaan,项目名称:hands-on-with-multichain,代码行数:32,代码来源:ValidateDocumentCommand.php


示例16: testUnpacking

 public function testUnpacking()
 {
     $request = EndRequest::unpack(hex2bin(self::$rawMessage));
     $this->assertEquals(FCGI::END_REQUEST, $request->getType());
     $this->assertEquals(FCGI::REQUEST_COMPLETE, $request->getProtocolStatus());
     $this->assertEquals(100, $request->getAppStatus());
 }
开发者ID:lisachenko,项目名称:protocol-fcgi,代码行数:7,代码来源:EndRequestTest.php


示例17: testCoordsToWkbShouldReturnTheCorrectHexString

 public function testCoordsToWkbShouldReturnTheCorrectHexString()
 {
     $lat = -2.714586;
     $lng = 15.419785;
     $expected = hex2bin('000000000101000000876F61DD78B705C0E5B33C0FEED62E40');
     $this->assertEquals($expected, Utils::coordsToWkb($lat, $lng));
 }
开发者ID:evalua,项目名称:php-toolbox,代码行数:7,代码来源:UtilsTest.php


示例18: display

 function display($tpl = null)
 {
     $game_id = bin2hex(JRequest::getVar('game_id'));
     $greeting = "Hola mundo Games" . hex2bin($game_id);
     $this->assignRef('greeting', $greeting);
     parent::display($tpl);
 }
开发者ID:akksi,项目名称:jcg,代码行数:7,代码来源:view.html.php


示例19: encode_password

function encode_password($plain, $challenge, $secret)
{
    if (strlen($challenge) % 2 != 0 || strlen($challenge) == 0) {
        return FALSE;
    }
    $hexchall = hex2bin($challenge);
    if ($hexchall === FALSE) {
        return FALSE;
    }
    if (strlen($secret) > 0) {
        $crypt_secret = md5($hexchall . $secret, TRUE);
        $len_secret = 16;
    } else {
        $crypt_secret = $hexchall;
        $len_secret = strlen($hexchall);
    }
    /* simulate C style \0 terminated string */
    $plain .= "";
    $crypted = '';
    for ($i = 0; $i < strlen($plain); $i++) {
        $crypted .= $plain[$i] ^ $crypt_secret[$i % $len_secret];
    }
    $extra_bytes = 0;
    //rand(0, 16);
    for ($i = 0; $i < $extra_bytes; $i++) {
        $crypted .= chr(rand(0, 255));
    }
    return bin2hex($crypted);
}
开发者ID:ozrouter,项目名称:docs,代码行数:29,代码来源:splash.php


示例20: verify

 /**
  * 验签
  *
  * @param string $data
  * @param string $sign
  * @param string $pem
  * @return bool 验签状态
  */
 private function verify($data, $sign)
 {
     $p = openssl_pkey_get_public(file_get_contents($this->chinaums_config['publickKey']));
     $verify = openssl_verify($data, hex2bin($sign), $p);
     openssl_free_key($p);
     return $verify > 0;
 }
开发者ID:yishuixm,项目名称:online-pay,代码行数:15,代码来源:ChinaumsNotify.php



注:本文中的hex2bin函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP hex2dec函数代码示例发布时间:2022-05-15
下一篇:
PHP hesk_validateEmail函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap