本文整理汇总了PHP中tk_decrypt函数的典型用法代码示例。如果您正苦于以下问题:PHP tk_decrypt函数的具体用法?PHP tk_decrypt怎么用?PHP tk_decrypt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tk_decrypt函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: check_crypt_balance_range
function check_crypt_balance_range($public_key, $block_start = 0, $block_end = 0)
{
set_decrypt_mode();
// Figure out which decrypt method can be best used
//Initialize objects for Internal RSA decrypt
if ($GLOBALS['decrypt_mode'] == 2) {
require_once 'RSA.php';
$rsa = new Crypt_RSA();
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
}
if ($block_start == 0 && $block_end == 0) {
// Find every Time Koin sent to this public Key
$sql = "SELECT public_key_from, public_key_to, crypt_data3, attribute FROM `transaction_history` WHERE `public_key_from` = '{$public_key}' OR `public_key_to` = '{$public_key}' ";
} else {
// Find every TimeKoin sent to and from this public Key in a certain time range.
// Covert block to time.
$start_time_range = TRANSACTION_EPOCH + $block_start * 300;
$end_time_range = TRANSACTION_EPOCH + $block_end * 300;
$sql = "SELECT public_key_from, public_key_to, crypt_data3, attribute FROM `transaction_history` WHERE (`public_key_from` = '{$public_key}' AND `timestamp` >= '{$start_time_range}' AND `timestamp` < '{$end_time_range}')\n\t\tOR (`public_key_to` = '{$public_key}' AND `timestamp` >= '{$start_time_range}' AND `timestamp` < '{$end_time_range}')";
}
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
$crypto_balance = 0;
$transaction_info;
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_row($sql_result);
$public_key_from = $sql_row[0];
$public_key_to = $sql_row[1];
$crypt3 = $sql_row[2];
$attribute = $sql_row[3];
if ($attribute == "G" && $public_key_from == $public_key_to) {
// Currency Generation
// Decrypt transaction information
if ($GLOBALS['decrypt_mode'] == 2) {
$rsa->loadKey($public_key_from);
$transaction_info = $rsa->decrypt(base64_decode($crypt3));
} else {
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE);
}
$transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
$crypto_balance += $transaction_amount_sent;
}
if ($attribute == "T" && $public_key_to == $public_key) {
// Decrypt transaction information
if ($GLOBALS['decrypt_mode'] == 2) {
$rsa->loadKey($public_key_from);
$transaction_info = $rsa->decrypt(base64_decode($crypt3));
} else {
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE);
}
$transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
$crypto_balance += $transaction_amount_sent;
}
if ($attribute == "T" && $public_key_from == $public_key) {
// Decrypt transaction information
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3));
if ($GLOBALS['decrypt_mode'] == 2) {
$rsa->loadKey($public_key_from);
$transaction_info = $rsa->decrypt(base64_decode($crypt3));
} else {
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE);
}
$transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
$crypto_balance -= $transaction_amount_sent;
}
}
//
// Unset variable to free up RAM
unset($sql_result);
return $crypto_balance;
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:71,代码来源:function.php
示例2: find_string
$transaction_hash = find_string("-----hash{$tc}=", "-----attribute{$tc}", $poll_peer);
$transaction_attribute = find_string("-----attribute{$tc}=", "-----end{$tc}", $poll_peer);
if (empty($transaction_public_key_from) == TRUE && empty($transaction_public_key_to) == TRUE) {
// No more data, break while loop
break;
}
$transaction_public_key_from = filter_sql(base64_decode($transaction_public_key_from));
$transaction_public_key_to = filter_sql(base64_decode($transaction_public_key_to));
// Check for valid attribute
if ($transaction_attribute == "G" || $transaction_attribute == "T" || $transaction_attribute == "H") {
if ($transaction_attribute == "G" || $transaction_attribute == "T") {
// Check that verification hash for transaction data matches
$crypt_hash_check = hash('sha256', $transaction_crypt1 . $transaction_crypt2 . $transaction_crypt3);
// Find destination public key
$public_key_to_1 = tk_decrypt($transaction_public_key_from, base64_decode($transaction_crypt1));
$public_key_to_2 = tk_decrypt($transaction_public_key_from, base64_decode($transaction_crypt2));
$internal_public_key_to = $public_key_to_1 . $public_key_to_2;
if ($transaction_hash == $crypt_hash_check && strlen($transaction_public_key_from) > 300 && strlen($transaction_public_key_to) > 300 && $internal_public_key_to == $transaction_public_key_to) {
// Continue with duplicate record test
$found_duplicate = mysql_result(mysql_query("SELECT timestamp FROM `transaction_history` WHERE `timestamp` = '{$transaction_timestamp}' AND `hash` = '{$transaction_hash}' LIMIT 1"), 0, 0);
} else {
// Use duplicate test to fail this transaction data
$found_duplicate = "INVALID";
}
} else {
// Transaction Cycle Hash, continue duplicate record test
$found_duplicate = mysql_result(mysql_query("SELECT timestamp FROM `transaction_history` WHERE `timestamp` = '{$transaction_timestamp}' AND `hash` = '{$transaction_hash}' LIMIT 1"), 0, 0);
}
if (empty($found_duplicate) == TRUE) {
$norm_record_insert_counter++;
// How many records are spooling up
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:transclerk.php
示例3: intval
$transaction_amount_sent_test = intval($transaction_amount_sent);
if ($transaction_amount_sent_test == $transaction_amount_sent) {
// Is a valid integer
$amount_valid = TRUE;
} else {
// Is NOT a valid integer
$amount_valid = FALSE;
}
// Validate transaction against known public key balance
if (check_crypt_balance($public_key) >= $transaction_amount_sent && $transaction_amount_sent > 0 && $amount_valid == TRUE) {
// Balance checks out
// Check hash value for tampering of crypt1, crypt2, or crypt3 fields
if (hash('sha256', $crypt1 . $crypt2 . $crypt3) == $hash_check) {
// Find destination public key
$public_key_to_1 = tk_decrypt($public_key, base64_decode($crypt1));
$public_key_to_2 = tk_decrypt($public_key, base64_decode($crypt2));
$public_key_to = $public_key_to_1 . $public_key_to_2;
if (strlen($public_key) > 300 && strlen($public_key_to) > 300 && $public_key !== $public_key_to) {
// Public key not found, insert into final transaction history
$sql = "INSERT INTO `transaction_history` (`timestamp` ,`public_key_from` , `public_key_to` , `crypt_data1` ,`crypt_data2` ,`crypt_data3` ,`hash` ,`attribute`)\n\t\t\t\t\t\t\t\tVALUES ({$time_created}, '{$public_key}', '{$public_key_to}' , '{$crypt1}', '{$crypt2}', '{$crypt3}', '{$hash_check}', 'T');";
if (mysql_query($sql) == FALSE) {
//Something didn't work
write_log("Transaction Database Insert Failed for this Key:" . base64_encode($public_key), "T");
}
} else {
// Invalid or blank Public Key(s)
write_log("Transaction Public Key Error for this Key:" . base64_encode($public_key), "T");
$safe_delete_transaction = TRUE;
}
} else {
// Hash check failed
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:treasurer.php
示例4: mysql_query
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
$body_string = '<strong><font color="blue">( ' . number_format($sql_num_results) . ' )</font> Network Transactions Waiting for Processing</strong><br><br><div class="table"><table class="listing" border="0" cellspacing="0" cellpadding="0" ><tr><th>Date</th>
<th>Sent From</th><th>Sent To</th><th>Amount</th></tr>';
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_array($sql_result);
$crypt1 = $sql_row["crypt_data1"];
$crypt2 = $sql_row["crypt_data2"];
$crypt3 = $sql_row["crypt_data3"];
$public_key_trans = $sql_row["public_key"];
// Decode the public key this transaction is being sent to
$public_key_to_1 = tk_decrypt($public_key_trans, base64_decode($crypt1));
$public_key_to_2 = tk_decrypt($public_key_trans, base64_decode($crypt2));
$public_key_trans_to = $public_key_to_1 . $public_key_to_2;
// Decode Amount
$transaction_info = tk_decrypt($public_key_trans, base64_decode($crypt3));
$transaction_amount = find_string("AMOUNT=", "---TIME", $transaction_info);
if ($public_key_trans == $my_public_key) {
if ($public_key_trans_to == $my_public_key) {
// Currency Generation
$public_key_from = '<td class="style2"><font color="blue">Currency Generation</font>';
$public_key_to = '<td class="style2"><font color="green">Self</font>';
} else {
// Self Generated to someone else
$public_key_from = '<td class="style2"><font color="blue">Self Generated Transaction</font>';
$public_key_to = '<td class="style1"><p style="word-wrap:break-word; width:215px; font-size:' . $default_public_key_font . 'px;">' . base64_encode($public_key_trans_to) . '</p>';
}
} else {
// Everyone else
if ($sql_row["attribute"] == "G") {
$public_key_to = '<td class="style2"><font color="green">Currency Generation</font>';
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:index.php
示例5: tk_decrypt
if ($transaction_info == $crypt2) {
// Check the IP/Domain field and poll the IP to see if
// there is a valid Timekoin server at the address.
$crypt3_data = tk_decrypt($public_key, base64_decode($crypt3));
$peer_ip = find_string("---ip=", "---domain", $crypt3_data);
$peer_domain = find_string("---domain=", "---subfolder", $crypt3_data);
$peer_subfolder = find_string("---subfolder=", "---port", $crypt3_data);
$peer_port_number = find_string("---port=", "---end", $crypt3_data);
$delete_request = find_string("---end=", "---end2", $crypt3_data);
// Check if IP is already in the generation peer list
$IP_exist1 = mysql_result(mysql_query("SELECT * FROM `generating_peer_list` WHERE `IP_Address` = '{$peer_ip}' LIMIT 1"), 0, 1);
// Calculate public key half-crypt-hash
$arr1 = str_split($public_key, 181);
// Poll the address that was encrypted to check for valid Timekoin server
$gen_key_crypt = base64_decode(poll_peer($peer_ip, $peer_domain, $peer_subfolder, $peer_port_number, 256, "genpeer.php?action=gen_key_crypt"));
$gen_key_crypt = tk_decrypt($public_key, $gen_key_crypt);
$domain_fail = FALSE;
// Reset Variable
if (empty($peer_domain) == FALSE) {
// Check if the hostname and IP fields actually match
// and not made up or unrelated.
$dns_ip = gethostbyname($peer_domain);
if ($dns_ip != $peer_ip) {
// No match between Domain IP and Encoded IP
$domain_fail = TRUE;
} else {
$domain_fail = FALSE;
}
}
// Does the public key half match what is encrypted in the 3rd crypt field from
// the same peer?
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:genpeer.php
示例6: mysql_num_rows
$sql_num_results = mysql_num_rows($sql_result);
$crypto_balance = 0;
$transaction_info;
for ($i = 0; $i < $sql_num_results; $i++) {
$sql_row = mysql_fetch_row($sql_result);
$public_key_from = $sql_row[0];
$public_key_to = $sql_row[1];
$crypt3 = $sql_row[2];
$attribute = $sql_row[3];
if ($attribute == "G" && $public_key_from == $public_key_to) {
// Decrypt transaction information
if ($GLOBALS['decrypt_mode'] == 2) {
$rsa->loadKey($public_key_from);
$transaction_info = $rsa->decrypt(base64_decode($crypt3));
} else {
$transaction_info = tk_decrypt($public_key_from, base64_decode($crypt3), TRUE);
}
$transaction_amount_sent = find_string("AMOUNT=", "---TIME", $transaction_info);
$crypto_balance += $transaction_amount_sent;
}
}
echo $crypto_balance;
}
// End Permission Check
// Log inbound IP activity
log_ip("AP", scale_trigger(100));
exit;
}
//***********************************************************************************
//***********************************************************************************
// Log IP even when not using any functions, just in case
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:api.php
示例7: write_log
write_log("Queue Hash Data MisMatch for Public Key: " . $transaction_public_key, "QC");
$transaction_attribute = "mismatch";
$mismatch_error_count++;
}
$transaction_public_key = filter_sql(base64_decode($transaction_public_key));
if ($transaction_attribute == "R") {
// Check to make sure this public key isn't forged or made up to win the list
$inside_transaction_hash = tk_decrypt($transaction_public_key, base64_decode($transaction_crypt1));
$final_hash_compare = $transaction_crypt2;
$crypt_hash_check = $transaction_hash;
} else {
if ($transaction_attribute == "T" || $transaction_attribute == "G") {
// Decrypt transaction information for regular transaction data
// and check to make sure the public key that is being sent to
// has not been tampered with.
$transaction_info = tk_decrypt($transaction_public_key, base64_decode($transaction_crypt3));
$inside_transaction_hash = find_string("HASH=", "", $transaction_info, TRUE);
// Check if a message is encoded in this data as well
if (strlen($inside_transaction_hash) != 64) {
// A message is also encoded
$inside_transaction_hash = find_string("HASH=", "---MSG", $transaction_info);
}
// Check Hash against 3 crypt fields
$crypt_hash_check = hash('sha256', $transaction_crypt1 . $transaction_crypt2 . $transaction_crypt3);
}
$final_hash_compare = hash('sha256', $transaction_crypt1 . $transaction_crypt2);
}
// Check to make sure this transaction is even valid (hash check, length check, & timestamp)
if ($transaction_hash == $crypt_hash_check && $inside_transaction_hash == $final_hash_compare && strlen($transaction_public_key) > 300 && $transaction_timestamp >= $current_generation_cycle && $transaction_timestamp < $next_generation_cycle) {
// Check for 100 public key limit in the transaction queue
$sql = "SELECT * FROM `transaction_queue` WHERE `public_key` = '{$transaction_public_key}'";
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:queueclerk.php
示例8: microtime
$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';
}
}
// Main Body Text
$body_string = '<FORM ACTION="cryptobenchmark.php?action=crypt" METHOD="post">
Choose bits: <input type="text" size="20" name="crypt_bits" value="' . $bits_level . '" /><br><br>
Data to Encrypt: <textarea name="encrypt_me" rows="6" cols="75">' . $encrypt_data . '</textarea><hr>
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:31,代码来源:cryptobenchmark.php
示例9: transaction_queue
//.........这里部分代码省略.........
}
}
}
// End for Loop
}
// End number of results check
// Compare tallies
if ($transaction_queue_hash_different > 0) {
// Transaction Queue still not in sync with all peers
$hash_array = array();
$transaction_counter = 0;
for ($i = 1; $i < $transaction_queue_hash_different + 1; $i++) {
$ip_address = $hash_different["ip_address{$i}"];
$domain = $hash_different["domain{$i}"];
$subfolder = $hash_different["subfolder{$i}"];
$port_number = $hash_different["port_number{$i}"];
$poll_peer = poll_peer($ip_address, $domain, $subfolder, $port_number, 8200, "queueclerk.php?action=queue&client=api");
// Bring up first match (if any) to compare agaist our database
$match_number = 1;
$current_hash = find_string("---queue{$match_number}=", "---end{$match_number}", $poll_peer);
$transaction_counter = 0;
$peer_transaction_limit = 100;
$mismatch_error_count = 0;
$mismatch_error_limit = 10;
while (empty($current_hash) == FALSE) {
// Count transactions coming from this peer
$transaction_counter++;
if ($transaction_counter > $peer_transaction_limit) {
break;
}
if ($mismatch_error_count > $mismatch_error_limit) {
break;
}
//Check if this transaction is already in our queue
$hash_match = mysql_result(mysql_query("SELECT hash FROM `transaction_queue` WHERE `hash` = '{$current_hash}' LIMIT 1"), 0, 0);
if (empty($hash_match) == TRUE) {
// This peer has a different transaction, ask for the full details of it
$poll_hash = poll_peer($ip_address, $domain, $subfolder, $port_number, 1500, "queueclerk.php?action=transaction&number={$current_hash}&client=api");
$transaction_timestamp = filter_sql(find_string("-----timestamp=", "-----public_key", $poll_hash));
$transaction_public_key = find_string("-----public_key=", "-----crypt1", $poll_hash);
$transaction_crypt1 = filter_sql(find_string("-----crypt1=", "-----crypt2", $poll_hash));
$transaction_crypt2 = filter_sql(find_string("-----crypt2=", "-----crypt3", $poll_hash));
$transaction_crypt3 = filter_sql(find_string("-----crypt3=", "-----hash", $poll_hash));
$transaction_hash = filter_sql(find_string("-----hash=", "-----attribute", $poll_hash));
$transaction_attribute = find_string("-----attribute=", "-----end", $poll_hash);
$transaction_qhash = find_string("---qhash=", "---endqhash", $poll_hash);
// If a qhash is included, use this to verify the data
if (empty($transaction_qhash) == FALSE) {
$qhash = $transaction_timestamp . $transaction_public_key . $transaction_crypt1 . $transaction_crypt2 . $transaction_crypt3 . $transaction_hash . $transaction_attribute;
$qhash = hash('md5', $qhash);
// Compare hashes to make sure data is intact
if ($transaction_qhash != $qhash) {
$transaction_attribute = "mismatch";
$mismatch_error_count++;
}
} else {
// Qhash is required to match hash now
$transaction_attribute = "mismatch";
$mismatch_error_count++;
}
$transaction_public_key = filter_sql(base64_decode($transaction_public_key));
if ($transaction_attribute == "T" || $transaction_attribute == "G") {
// Decrypt transaction information for regular transaction data
// and check to make sure the public key that is being sent to
// has not been tampered with.
$transaction_info = tk_decrypt($transaction_public_key, base64_decode($transaction_crypt3));
$inside_transaction_hash = find_string("HASH=", "", $transaction_info, TRUE);
// Check if a message is encoded in this data as well
if (strlen($inside_transaction_hash) != 64) {
// A message is also encoded
$inside_transaction_hash = find_string("HASH=", "---MSG", $transaction_info);
}
// Check Hash against 3 crypt fields
$crypt_hash_check = hash('sha256', $transaction_crypt1 . $transaction_crypt2 . $transaction_crypt3);
}
$final_hash_compare = hash('sha256', $transaction_crypt1 . $transaction_crypt2);
// Check to make sure this transaction is even valid (hash check, length check, & timestamp)
if ($transaction_hash == $crypt_hash_check && $inside_transaction_hash == $final_hash_compare && strlen($transaction_public_key) > 300 && $transaction_timestamp >= $current_transaction_cycle && $transaction_timestamp < $next_transaction_cycle) {
// Check for 100 public key limit in the transaction queue
$sql = "SELECT timestamp FROM `transaction_queue` WHERE `public_key` = '{$transaction_public_key}'";
$sql_result = mysql_query($sql);
$sql_num_results = mysql_num_rows($sql_result);
if ($sql_num_results < 100) {
// Transaction hash and real hash match
$sql = "INSERT INTO `transaction_queue` (`timestamp`,`public_key`,`crypt_data1`,`crypt_data2`,`crypt_data3`, `hash`, `attribute`)\n\t\t\t\t\t\t\tVALUES ('{$transaction_timestamp}', '{$transaction_public_key}', '{$transaction_crypt1}', '{$transaction_crypt2}' , '{$transaction_crypt3}', '{$transaction_hash}' , '{$transaction_attribute}')";
mysql_query($sql);
}
}
}
// End Empty Hash Check
$match_number++;
$current_hash = find_string("---queue{$match_number}=", "---end{$match_number}", $poll_peer);
}
// End While Loop
}
// End For Loop
}
// End Compare Tallies
return;
}
开发者ID:LoveLeAnon,项目名称:timekoin,代码行数:101,代码来源:task.php
注:本文中的tk_decrypt函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论