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

PHP tk_encrypt函数代码示例

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

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



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

示例1: send_timekoins

function send_timekoins($my_private_key, $my_public_key, $send_to_public_key, $amount, $message)
{
    $arr1 = str_split($send_to_public_key, 181);
    $encryptedData1 = tk_encrypt($my_private_key, $arr1[0]);
    $encryptedData64_1 = base64_encode($encryptedData1);
    $encryptedData2 = tk_encrypt($my_private_key, $arr1[1]);
    $encryptedData64_2 = base64_encode($encryptedData2);
    // Sanitization of message
    // Filter symbols that might lead to a transaction hack attack
    $symbols = array("|", "?", "=");
    // SQL + URL
    $message = str_replace($symbols, "", $message);
    // Trim any message to 64 characters max and filter any sql
    $message = filter_sql(substr($message, 0, 64));
    $transaction_data = "AMOUNT={$amount}---TIME=" . time() . "---HASH=" . hash('sha256', $encryptedData64_1 . $encryptedData64_2) . "---MSG={$message}";
    $encryptedData3 = tk_encrypt($my_private_key, $transaction_data);
    $encryptedData64_3 = base64_encode($encryptedData3);
    $triple_hash_check = hash('sha256', $encryptedData64_1 . $encryptedData64_2 . $encryptedData64_3);
    $sql = "INSERT INTO `my_transaction_queue` (`timestamp`,`public_key`,`crypt_data1`,`crypt_data2`,`crypt_data3`, `hash`, `attribute`) VALUES \n\t\t('" . time() . "', '{$my_public_key}', '{$encryptedData64_1}', '{$encryptedData64_2}' , '{$encryptedData64_3}', '{$triple_hash_check}' , 'T')";
    if (mysql_query($sql) == TRUE) {
        // Success code
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:26,代码来源:function.php


示例2: mysql_result

                 // Server public key is listed as a qualified generation server.
                 // Has the server submitted it's currency generation to the transaction queue?
                 $found_public_key_my_queue = mysql_result(mysql_query("SELECT * FROM `my_transaction_queue` WHERE `attribute` = 'G' LIMIT 1"), 0, "timestamp");
                 $found_public_key_trans_queue = mysql_result(mysql_query("SELECT * FROM `transaction_queue` WHERE `public_key` = '{$my_public_key}' AND `attribute` = 'G' LIMIT 1"), 0, "timestamp");
                 $join_peer_list = mysql_result(mysql_query("SELECT * FROM `generating_peer_list` WHERE `public_key` = '{$my_public_key}' LIMIT 1"), 0, "join_peer_list");
                 if (empty($found_public_key_my_queue) == TRUE && empty($found_public_key_trans_queue) == TRUE && time() - $join_peer_list >= 3600) {
                     // How much can be generated at one time?
                     $allowed_amount = peer_gen_amount($my_public_key);
                     //Not found, add it to transaction queue
                     $arr1 = str_split($my_public_key, 181);
                     $encryptedData1 = tk_encrypt($my_private_key, $arr1[0]);
                     $encryptedData64_1 = base64_encode($encryptedData1);
                     $encryptedData2 = tk_encrypt($my_private_key, $arr1[1]);
                     $encryptedData64_2 = base64_encode($encryptedData2);
                     $transaction_data = "AMOUNT={$allowed_amount}---TIME=" . time() . "---HASH=" . hash('sha256', $encryptedData64_1 . $encryptedData64_2);
                     $encryptedData3 = tk_encrypt($my_private_key, $transaction_data);
                     $encryptedData64_3 = base64_encode($encryptedData3);
                     $duplicate_hash_check = hash('sha256', $encryptedData64_1 . $encryptedData64_2 . $encryptedData64_3);
                     $sql = "INSERT INTO `my_transaction_queue` (`timestamp`,`public_key`,`crypt_data1`,`crypt_data2`,`crypt_data3`, `hash`, `attribute`)\n\t\t\t\t\tVALUES ('" . time() . "', '{$my_public_key}', '{$encryptedData64_1}', '{$encryptedData64_2}' , '{$encryptedData64_3}', '{$duplicate_hash_check}' , 'G')";
                     mysql_query($sql);
                 }
             }
             // Future generation allowed check
         }
         // Public Key Check
     }
     // Generation enabled check
 }
 // End Time allowed check
 //***********************************************************************************
 //***********************************************************************************
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:generation.php


示例3: send_timekoins

function send_timekoins($my_private_key, $my_public_key, $send_to_public_key, $amount, $message)
{
    if (empty($my_private_key) == TRUE || empty($my_public_key) == TRUE || empty($send_to_public_key) == TRUE) {
        return FALSE;
    }
    ini_set('user_agent', 'Timekoin Client v' . TIMEKOIN_VERSION);
    ini_set('default_socket_timeout', 3);
    // Timeout for request in seconds
    $arr1 = str_split($send_to_public_key, 181);
    $encryptedData1 = tk_encrypt($my_private_key, $arr1[0]);
    $encryptedData64_1 = base64_encode($encryptedData1);
    $encryptedData2 = tk_encrypt($my_private_key, $arr1[1]);
    $encryptedData64_2 = base64_encode($encryptedData2);
    // Sanitization of message
    // Filter symbols that might lead to a transaction hack attack
    $symbols = array("|", "?", "=");
    // SQL + URL
    $message = str_replace($symbols, "", $message);
    // Trim any message to 64 characters max and filter any sql
    $message = filter_sql(substr($message, 0, 64));
    $transaction_data = "AMOUNT={$amount}---TIME=" . time() . "---HASH=" . hash('sha256', $encryptedData64_1 . $encryptedData64_2) . "---MSG={$message}";
    $encryptedData3 = tk_encrypt($my_private_key, $transaction_data);
    $encryptedData64_3 = base64_encode($encryptedData3);
    $triple_hash_check = hash('sha256', $encryptedData64_1 . $encryptedData64_2 . $encryptedData64_3);
    $timestamp = transaction_cycle(0) + 1;
    $attribute = "T";
    $qhash = $timestamp . base64_encode($my_public_key) . $encryptedData64_1 . $encryptedData64_2 . $encryptedData64_3 . $triple_hash_check . $attribute;
    $qhash = hash('md5', $qhash);
    // Create map with request parameters
    $params = array('timestamp' => $timestamp, 'public_key' => base64_encode($my_public_key), 'crypt_data1' => $encryptedData64_1, 'crypt_data2' => $encryptedData64_2, 'crypt_data3' => $encryptedData64_3, 'hash' => $triple_hash_check, 'attribute' => $attribute, 'qhash' => $qhash);
    // Build Http query using params
    $query = http_build_query($params);
    // Create Http context details
    $contextData = array('method' => 'POST', 'header' => "Connection: close\r\n" . "Content-Length: " . strlen($query) . "\r\n", 'content' => $query);
    // Create context resource for our request
    $context = stream_context_create(array('http' => $contextData));
    // Try all Active Peer Servers
    $sql_result = mysql_query("SELECT * FROM `active_peer_list` ORDER BY RAND()");
    $sql_num_results = mysql_num_rows($sql_result);
    $return_results;
    for ($i = 0; $i < $sql_num_results; $i++) {
        $sql_row = mysql_fetch_array($sql_result);
        $ip_address = $sql_row["IP_Address"];
        $domain = $sql_row["domain"];
        $subfolder = $sql_row["subfolder"];
        $port_number = $sql_row["port_number"];
        $code = $sql_row["code"];
        $poll_peer = filter_sql(poll_peer($ip_address, $domain, $subfolder, $port_number, 5, "api.php?action=send_tk&hash={$code}", $context));
        if ($poll_peer == "OK") {
            write_log("Peer: [{$ip_address}{$domain}:{$port_number}/{$subfolder}] Accepted the Transaction for Processing", "T");
            $return_results = TRUE;
        }
    }
    if ($return_results == TRUE) {
        // Success in sending transaction
        return TRUE;
    } else {
        // No peer servers accepted the transaction data :(
        write_log("No Peers Accepted the Transaction", "T");
        return FALSE;
    }
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:62,代码来源:function.php


示例4: microtime

     $encrypt_data = $_POST["encrypt_me"];
     if (empty($encrypt_data) == TRUE) {
         $encrypt_data = "empty";
     }
     $key_create_micro_time = microtime(TRUE);
     require_once '../RSA.php';
     $rsa = new Crypt_RSA();
     extract($rsa->createKey($bits_level));
     $key_create_micro_time_done = microtime(TRUE);
     if (empty($privatekey) == FALSE && empty($publickey) == FALSE) {
         $symbols = array("\r");
         $new_publickey = str_replace($symbols, "", $publickey);
         $new_privatekey = str_replace($symbols, "", $privatekey);
         $encrypt_create_micro_time = microtime(TRUE);
         // Encrypt New Data
         $encrypt_data_new = tk_encrypt($new_privatekey, $encrypt_data);
         $encrypt_create_micro_time_done = microtime(TRUE);
         $decrypt_create_micro_time = microtime(TRUE);
         // Now Decrypt the same Data
         $decrypted_data = tk_decrypt($new_publickey, $encrypt_data_new);
         $decrypt_create_micro_time_done = microtime(TRUE);
         if (empty($decrypted_data) == TRUE) {
             $decrypted_data = '***DATA STRING TOO LONG FOR BITS ENTERED***';
         }
         $micro_time_variance = "Key Pair Creation [<strong>" . round(($key_create_micro_time_done - $key_create_micro_time) * 1000) . "</strong>] ms<br>\n\t\t\t\tData Encryption [<strong>" . round(($encrypt_create_micro_time_done - $encrypt_create_micro_time) * 1000) . "</strong>] ms<br>\n\t\t\t\tData Decryption [<strong>" . round(($decrypt_create_micro_time_done - $decrypt_create_micro_time) * 1000) . "</strong>] ms<br>\n\t\t\t\tTotal Time [<strong>" . round((microtime(TRUE) - $key_create_micro_time) * 1000) . "</strong>] ms";
         $text_bar .= " {$micro_time_variance} for <strong>{$bits_level}</strong> bit RSA Encryption";
     } else {
         // Key Pair Creation Error
         $text_bar = 'Key Creation Failed';
     }
 }
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:cryptobenchmark.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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