本文整理匯總了PHP中strToHex函數的典型用法代碼示例。如果您正苦於以下問題:PHP strToHex函數的具體用法?PHP strToHex怎麽用?PHP strToHex使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了strToHex函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: BlockIo
/* This example script does the following:
This script converts a given string into a Private Key for a specific address.
Useful for extracting Private Keys in Wallet Import Format when using Distributed Trust,
and mop-py to sweep coins out of the Distributed Trust address without going through Block.io.
IMPORTANT! Specify your own API Key here.
The network to use for the Wallet Import Format is determined from the API Key used.
Contact support@block.io for any help with this.
*/
<?php
require_once 'path/to/block_io.php';
/* Replace the $apiKey with the API Key from your Block.io Wallet. */
$apiKey = 'YOUR API KEY';
$pin = 'PIN - NOT NEEDED';
$version = 2;
// the API version
$block_io = new BlockIo($apiKey, $pin, $version);
$network = $block_io->get_balance()->data->network;
// get our current network off Block.io
$passphrase = strToHex('alpha1alpha2alpha3alpha4');
$key = $block_io->initKey()->fromPassphrase($passphrase);
echo "Current Network: " . $network . "\n";
echo "Private Key: " . $key->toWif($network) . "\n";
// print out the private key for the given network
示例2: StateMsg
function StateMsg($msgs)
{
$str = explode("", $msgs);
$ste = 0;
if (count($str) > 3) {
switch ($str[0]) {
case 'success':
$ste = 1;
break;
/*成功返回*/
/*成功返回*/
case 'serror':
$ste = -1;
break;
/*錯誤返回*/
}
if (0 != $ste) {
if (strlen($str[3]) > 1) {
$mstr = '0x' . strToHex($str[3]);
} else {
$mstr = '""';
}
$hsql = 'update task_tab set msg=' . $mstr . ",ste={$ste} where id=" . $str[1] . ' and tkey="' . $str[2] . '"';
if (!HwExec($hsql)) {
WebCenterLogs('[' . $_SERVER['REMOTE_ADDR'] . ']任務狀態更新-錯誤', $hsql);
}
} else {
WebCenterLogs('[' . $_SERVER['REMOTE_ADDR'] . ']節點狀態碼-錯誤', "未知返回狀態:\n" . $str[0]);
}
} else {
WebCenterLogs('[' . $_SERVER['REMOTE_ADDR'] . ']節點狀態碼-', strToHex($msgs));
}
}
示例3: tokenString
public static function tokenString($userId, $departmentId, $groupId, $created)
{
$tokenString = array();
$tokenString['userId'] = $userId;
$tokenString['departmentId'] = $departmentId;
$tokenString['groupId'] = $groupId;
$tokenString['created'] = $created;
return strToHex(\Think\Crypt\Driver\Base64::encrypt(json_encode($tokenString), 'easonchan'));
}
示例4: encrypt
function encrypt($string, $key)
{
$result = '';
for ($i = 0; $i < strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, $i % strlen($key) - 1, 1);
$char = chr(ord($char) + ord($keychar));
$result .= $char;
}
return strToHex($result);
}
示例5: HwCreateTask
function HwCreateTask($ip, $fid, $ftr)
{
global $link;
if (strlen($ip) > 30) {
return false;
} else {
$node = '0x' . strToHex($ip);
}
$dte = date('Y-m-d H:i:s');
$key = md5($ip . Rndkeys(32) . $dte, false);
$hsql = "insert into task_tab(ip,tkey,fid,fpath,dte)values({$node},'{$key}',{$fid},'{$ftr}','{$dte}')";
if (HwExec($hsql)) {
echo "successCreate task Success ~!";
HwSend($ip, '32303', $key);
} else {
echo "errorx1Fail to create task ~!";
}
return true;
}
示例6: verifyToken
public static function verifyToken($token)
{
$tokenString = hexToStr($token);
$jsonData = \Think\Crypt\Driver\Base64::decrypt($tokenString, 'easonchan');
$array = json_decode($jsonData, true);
if ($array == null) {
return false;
}
$created = $array['created'];
$expire = BoxTokenHelper::$expire;
$now = time();
if ($created + $expire < $now) {
return false;
}
$info = new TokenInfo($array['userId'], $array['departmentId'], $array['groupId'], $array['created']);
$array['created'] = time();
$tokenString = strToHex(\Think\Crypt\Driver\Base64::encrypt(json_encode($array), 'easonchan'));
return array('str' => $tokenString, 'info' => $info);
}
示例7: rcon
function rcon($serverip, $serverport, $rconpassword, $cmd)
{
$passhead = chr(0xff) . chr(0x0);
$head = chr(0x42) . chr(0x45);
$pass = $passhead . $rconpassword;
$answer = "";
$checksum = get_checksum($pass);
$loginmsg = $head . $checksum . $pass;
$rcon = fsockopen("udp://" . $serverip, $serverport, $errno, $errstr, 1);
stream_set_timeout($rcon, 5);
if (!$rcon) {
echo "ERROR: {$errno} - {$errstr}<br />\n";
} else {
fwrite($rcon, $loginmsg);
$res = fread($rcon, 16);
$cmdhead = chr(0xff) . chr(0x1) . chr(0x0);
//$cmd = "Players";
$cmd = $cmdhead . $cmd;
$checksum = get_checksum($cmd);
$cmdmsg = $head . $checksum . $cmd;
$hlen = strlen($head . $checksum . chr(0xff) . chr(0x1));
fwrite($rcon, $cmdmsg);
$answer = fread($rcon, 102400);
if (strToHex(substr($answer, 9, 1)) == "0") {
$count = strToHex(substr($answer, 10, 1));
//echo $count."<br/>";
for ($i = 0; $i < $count - 1; $i++) {
$answer .= fread($rcon, 102400);
}
}
//echo strToHex(substr($answer, 0, 16))."<br/>";
//echo strToHex($answer)."<br/>";
//echo $answer."<br/>";
$cmd = "Exit";
$cmd = $cmdhead . $cmd;
$checksum = get_checksum($cmd);
$cmdmsg = $head . $checksum . $cmd;
fwrite($rcon, $cmdmsg);
}
return $answer;
}
示例8: check_video
public function check_video($videoid)
{
$rows = $this->db->get_rows('videos', array(), "LIMIT 1000");
foreach ($rows as $row) {
extract($row);
$fh = fopen($storage, "rb");
if ($fh) {
$fheader = fread($fh, 20);
$fheader_hex = strToHex($fheader);
$fheader_printable = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', $fheader);
if (in_array($fheader_printable, $this->known_formats)) {
$known = "<font color='green'>[recognized]</font>";
} else {
$known = "<font color='red'>[not recognized]</font>";
}
$this->msg .= "File {$storage}, request {$request}, header {$fheader_printable}, hex {$fheader_hex} {$known}<br>\n";
fclose($fh);
} else {
$this->msg .= "File {$storage}, request {$request} not found!<br>\n";
}
}
}
示例9: HwCreateTask
function HwCreateTask($ip, $fid, $ftr)
{
global $link;
if (strlen($ip) > 30) {
return false;
} else {
$node = '0x' . strToHex($ip);
}
$dte = date('Y-m-d H:i:s');
$key = md5($ip . Rndkeys(32) . $dte . microtime(), false);
$hsql = "insert into task_tab(ip,tkey,fid,fpath,dte)values({$node},'{$key}',{$fid},'{$ftr}','{$dte}')";
if (HwExec($hsql)) {
if (HwSend($ip, '32303', $key) > -1) {
echo "success{$key}Create task Success ~!";
} else {
WebCenterLogs('[' . $ip . ']推送失敗', $hsql);
}
} else {
echo "errorx1{$key}Fail to create task ~!";
WebCenterLogs('[' . $ip . ']任務創建失敗', $hsql);
}
return true;
}
示例10: base64_encode
$objRotatividade->set_hor_entrada($hor_entrada);
$objRotatividade->set_dat_cadastro($dat_cadastro);
$objRotatividade->set_cod_rotatividade($cod_rotatividade);
$objRotatividade->set_hor_saida($hor_saida);
$objRotatividade->set_dat_saida($dat_saida);
$objRotatividade->set_cod_desconto($cod_desconto);
$objRotatividade->set_val_total(str_replace(",", ".", $val_total));
$objRotatividade->set_val_cobrado(str_replace(",", ".", $val_cobrado));
$objRotatividade->set_des_justificativa($des_justificativa);
$objRotatividade->set_tem_permanencia($tem_permanencia);
$objRotatividade->removeRotatividade($objRotatividade);
$objClientes->set_des_placa($des_placa);
$arrCliente = $objClientes->buscaClientes($objClientes);
$cod_cliente = $arrCliente[0]['cod_cliente'];
$msgRetorno = 'Veiculo liberado com sucesso';
$msgRetorno .= '<br> Deseja imprimir RPS? <a href="' . $url . 'rotatividade/index.php?imprimir=' . base64_encode(strToHex('imprimeRPS')) . '&cod_rotatividade=' . $cod_rotatividade . '&cod_cliente=' . $cod_cliente . '">Sim</a>';
$val_total = "";
}
}
if (isset($_GET) && !empty($_GET['imprimir'])) {
$cod_rotatividade = $_GET['cod_rotatividade'];
$cod_rotatividade = base64_decode(hexToStr($cod_rotatividade));
$cod_cliente = $_GET['cod_cliente'];
geraRPS($cod_rotatividade, 1, $cod_cliente);
Header("Location:" . $url . "rotatividade/index.php");
}
if (isset($_POST) && !empty($_POST['imprimirCupomEntrada']) && $verificaImprimir == true) {
$imprime_cupom = true;
}
//$hora_entrada = date("H:i:s");
$hora_entrada = "";
示例11: computverifier
function computverifier($srp, $user, $pwd, $salt)
{
// private key
$innerHash = $srp->hashHex(strToHex($user) . '3a' . strToHex($pwd));
$privateKey = $srp->hashHex($salt . $innerHash);
// verifier
$tmp = dec2hex(bcpowmod($srp->gdec(), hex2dec($privateKey), $srp->Ndec()));
$verifier = str_pad($tmp, strlen($srp->Nhex()), "0", STR_PAD_LEFT);
return $verifier;
}
示例12: ParseData
/**
* handle incoming data along capabilities
* @param array $data
*/
private function ParseData($data)
{
//
$caps = $this->GetCaps();
//$this->debug(__FUNCTION__,print_r($this->all_caps,true));
foreach (array_keys($caps) as $cap) {
$ident = $caps[$cap];
$vid = @$this->GetIDForIdent($ident);
if ($vid == 0) {
$this->debug(__FUNCTION__, "Cap {$cap} Ident {$ident}: Variable missed");
continue;
}
if (!isset($data[$cap])) {
continue;
}
$s = $data[$cap];
switch ($cap) {
//integer
case 'TS':
//Timestamp
//Timestamp
case 'Signal':
//RSSI
//RSSI
case 'Timer':
//Duration code
//Duration code
case 'Dimmer':
//intensity 100%
//intensity 100%
case 'Shutter':
//intensity 100%
$iv = (int) $s;
SetValueInteger($vid, $iv);
break;
//String
//String
case 'Name':
//Duration code
$st = utf8_decode($s);
SetValueString($vid, $st);
break;
//special
//special
case 'Switch':
//Status
$state = $this->SwitchStatus($s);
SetValueBoolean($vid, $state);
break;
case 'Lock':
//Status
$state = preg_match("/YES|CLOSE|OK/i", $s);
//reversed
SetValueBoolean($vid, $state);
break;
case 'Alert':
//Status
$state = !preg_match("/YES|ALERT/i", $s);
//reversed
SetValueBoolean($vid, $state);
break;
case 'Battery':
//battery
$state = !preg_match("/LOW|WARN/i", $s);
//reversed
SetValueBoolean($vid, $state);
break;
case 'FS20':
//fs20 mode decoding
$state = false;
$intensity = 0;
$timer = 0;
$acode = '';
$actioncode = '';
$code = utf8_decode($s);
$this->debug(__FUNCTION__, "FS20 Code " . strToHex($code));
$action = $code[0];
$ext = ord($code[1]);
$tvid = @$this->GetIDForIdent($caps['Timer']);
$dvid = @$this->GetIDForIdent($caps['Dimmer']);
$swid = @$this->GetIDForIdent($caps['Switch']);
$avid = @$this->GetIDForIdent($caps['TimerActionCode']);
$this->debug(__FUNCTION__, "FS20 Vars S:{$swid},D:{$dvid},T:{$tvid},A:{$avid}");
if ($dvid) {
$intensity = GetValueInteger($dvid);
}
if ($swid) {
$state = GetValueBoolean($swid);
}
if ($tvid) {
$timer = GetValueInteger($tvid);
}
if ($avid) {
$acode = GetValueString($avid);
}
$ac = ord($action) & 0x1f;
//.........這裏部分代碼省略.........
示例13: WebCenterLogs
function WebCenterLogs($title, $logbody = '')
{
global $link;
$hsql = 'insert into fw_log(jet,log,uid,ip,dte)values';
if (strlen($title) > 0) {
$jet = '0x' . strToHex($title);
} else {
$jet = '""';
}
if (strlen($logbody) > 0) {
$log = '0x' . strToHex($logbody);
} else {
$log = '0x' . strToHex($_SERVER['HTTP_USER_AGENT']);
}
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SESSION['#UID'])) {
$uid = $_SESSION['#UID'];
} else {
$uid = '"node"';
}
$dte = date('Y-m-d H:i:s');
$hsql .= "({$jet},{$log},{$uid},'{$ip}','{$dte}')";
HwExec($hsql);
}
示例14: str_replace
if (isset($_POST) && !empty($_POST['envia'])) {
$valor_pago = str_replace(",", ".", $_POST['valor_pago']);
$periodo_inicial = gravaData($_POST['periodo_inicial']);
$periodo_final = gravaData($_POST['periodo_final']);
$data_pagamento = gravaData($_POST['data_pagamento']);
$cod_cliente = $_POST['cod_cliente'];
$cod_mensalidade = $_POST['cod_mensalidade'];
$objMensalidadeUsuario->set_valor_pago($valor_pago);
$objMensalidadeUsuario->set_periodo_inicial($periodo_inicial);
$objMensalidadeUsuario->set_periodo_final($periodo_final);
$objMensalidadeUsuario->set_data_pagamento($data_pagamento);
$objMensalidadeUsuario->set_cod_cliente($cod_cliente);
$objMensalidadeUsuario->set_cod_mensalidade($cod_mensalidade);
$cod_pagamento = $objMensalidadeUsuario->cadastraPagamento();
$msgRetorno = "Pagamento registrado com sucesso";
$msgRetorno .= '<br> Deseja imprimir RPS? <a href="' . $url . 'admin/clientes/mensalidade.php?imprimir=' . base64_encode(strToHex('imprimeRPS')) . '&cod_pagamento=' . $cod_pagamento . '">Sim</a>';
$objMensalidadeUsuario->ResetObject();
}
if (isset($_POST) && !empty($_POST['ImprimirComprovante'])) {
$cod_mensalidade_usuario = $_POST['cod_mensalidade_usuario'];
$objMensalidadeUsuario->set_cod_mensalidade_usuario($cod_mensalidade_usuario);
$objMensalidadeUsuario->geraComprovante();
}
if (isset($_POST) && !empty($_POST['ExcluirPagamento'])) {
$cod_mensalidade_usuario = $_POST['cod_mensalidade_usuario'];
$cod_cliente = $_POST['cod_cliente'];
$objMensalidadeUsuario->set_cod_mensalidade_usuario($cod_mensalidade_usuario);
$msgRetorno = $objMensalidadeUsuario->excluirPagamento();
}
if (isset($_GET) && !empty($_GET['imprimir'])) {
$cod_pagamento = $_GET['cod_pagamento'];
示例15: Encrypt
function Encrypt($sValue, $sSecretKey)
{
return strToHex(rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, $sValue, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))), ""));
}