function encryptSymmetricAndMacKeyUsingRSA($sym, $mac) { $config = array("digest_alg" => "sha512", "private_key_bits" => 4096, "private_key_type" => OPENSSL_KEYTYPE_RSA); $privKey = NULL; $res = openssl_pkey_new($config); if ($res == false) { echo "pkey false"; } else { echo $res; } openssl_pkey_export($res, $privKey); $pubKey = openssl_pkey_get_details($res); $pubKey = $pubKey["key"]; $encryptedSymmetricKey = ";\n {$encryptedMacKey}="; openssl_public_encrypt($sym, $encryptedSymmetricKey, $pubkey); openssl_public_encrypt($mac, $encryptedMacKey, $pubkey); return storeInDatabase($encryptedSymmetricKey, $encryptedMacKey, $privKey); }
} if ($storeMonth && isset($unix_time)) { $result = getDataDaysBefore($unix_time); $totalMonth = 0; $i = 0; $time = ""; $tiemstamp = ""; foreach ($result as $value) { $totalMonth = $totalMonth + $value['total']; if ($i == 0) { $time = $value['date']; $timestamp = $value['unix_time']; } $i++; } storeInDatabase($time, $timestamp, $totalMonth, 2); deleteOldData($timestamp, 0); $timestamp = $timestamp - 380 * 24 * 60 * 60; deleteOldData($timestamp, 2); } function deleteOldData($unix_time, $type) { global $pDB; $query = "delete from email_statistics where unix_time < ? and type=?"; $result = $pDB->genQuery($query, array($unix_time, $type)); if ($result == FALSE) { wlog($pDB->errMsg . "\n"); } } function getDataDaysBefore($unix_time) {