本文整理汇总了PHP中mcrypt_ecb函数的典型用法代码示例。如果您正苦于以下问题:PHP mcrypt_ecb函数的具体用法?PHP mcrypt_ecb怎么用?PHP mcrypt_ecb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mcrypt_ecb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decrypt_aes_cbc
function decrypt_aes_cbc($key, $data, $iv = '')
{
$ksize = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$bsize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
if ($iv == '') {
$iv = str_repeat("", $bsize);
}
if (strlen($iv) != $bsize) {
echo 'Warning: IV must match block-size in length. Defaulting to null bytes.', PHP_EOL;
$iv = str_repeat("", $bsize);
}
if (strlen($key) > $ksize) {
die("Error: Maximum key-size for AES-128-CBC is {$ksize}." . PHP_EOL);
}
$blocks = str_split($data, $bsize);
$dec = mcrypt_ecb(MCRYPT_RIJNDAEL_128, $key, $blocks[0], MCRYPT_DECRYPT) ^ $iv;
for ($i = 1, $j = count($blocks); $i < $j; $i++) {
$dec .= mcrypt_ecb(MCRYPT_RIJNDAEL_128, $key, $blocks[$i], MCRYPT_DECRYPT) ^ $blocks[$i - 1];
}
try {
return strip_pkcs7($dec);
} catch (Exception $e) {
die($e->getMessage() . PHP_EOL);
}
}
示例2: decrypt
public function decrypt($cipher)
{
if ($this->blockmode == Lms_Crypt::MODE_ECB) {
$plain = mcrypt_ecb($this->alghoritm, $this->key, $cipher, MCRYPT_DECRYPT, $this->iv);
}
if ($this->blockmode == Lms_Crypt::MODE_CBC) {
$plain = mcrypt_cbc($this->alghoritm, $this->key, $cipher, MCRYPT_DECRYPT, $this->iv);
}
return $plain;
}
示例3: broker_user_update
public function broker_user_update()
{
if (isset($this->request->data['e']) || isset($this->request->data['u'])) {
$broker_key = Configure::read('hippo.sso_broker_key');
if ($broker_key) {
$this->loadModel('Agents');
$this->loadModel('Suppliers');
$key = substr($broker_key, 0, 5);
$DECRYPT_existing_email = '';
$DECRYPT_existing_username = '';
$DECRYPT_email = '';
$DECRYPT_username = '';
if (isset($this->request->data['ee'])) {
$DECRYPT_existing_email = mcrypt_ecb(MCRYPT_3DES, $key, base64_decode($this->request->data['ee']), MCRYPT_DECRYPT);
$DECRYPT_existing_email = ereg_replace("[[:cntrl:]]", "", $DECRYPT_existing_email);
}
if (isset($this->request->data['eu'])) {
$DECRYPT_existing_username = mcrypt_ecb(MCRYPT_3DES, $key, base64_decode($this->request->data['eu']), MCRYPT_DECRYPT);
$DECRYPT_existing_username = ereg_replace("[[:cntrl:]]", "", $DECRYPT_existing_username);
}
if (isset($this->request->data['e'])) {
$DECRYPT_email = mcrypt_ecb(MCRYPT_3DES, $key, base64_decode($this->request->data['e']), MCRYPT_DECRYPT);
$DECRYPT_email = ereg_replace("[[:cntrl:]]", "", $DECRYPT_email);
}
if (isset($this->request->data['u'])) {
$DECRYPT_username = mcrypt_ecb(MCRYPT_3DES, $key, base64_decode($this->request->data['u']), MCRYPT_DECRYPT);
$DECRYPT_username = ereg_replace("[[:cntrl:]]", "", $DECRYPT_username);
}
//attempt to find user in suppliers table
$user = $this->Suppliers->find('all', ['conditions' => ['username' => $DECRYPT_existing_username, 'email' => $DECRYPT_existing_email], ['accessibleFields' => ['username' => true]]]);
$type = 'supplier';
if ($user->count() == 0) {
//attempt to find user in suppliers table
$user = $this->Agents->find('all', ['conditions' => ['username' => $DECRYPT_existing_username, 'email' => $DECRYPT_existing_email], ['accessibleFields' => ['username' => true]]]);
$type = 'agent';
}
if ($user->count() > 0) {
$user = $user->first();
if (isset($DECRYPT_username)) {
$user->username = $DECRYPT_username;
}
if (isset($DECRYPT_email)) {
$user->email = $DECRYPT_email;
}
if ($type == 'supplier') {
$this->Suppliers->save($user);
} else {
$this->Agents->save($user);
}
}
}
}
return '';
}
示例4: containerExec
function containerExec($content)
{
global $DLC_KEY1, $DLC_KEY2;
if ($DLC_KEY1 == '' || $DLC_KEY2 == '') {
return 'ERROR: You have to set up the variable $DLC_KEY1 and $DLC_KEY2 in the dlc container module.';
}
$retval = '';
$TAILLEN = 88;
$IV = hex2bin('00000000000000000000000000000000');
$content = preg_replace('/[\\r\\n]+/s', '', $content);
$tail = substr($content, strlen($content) - $TAILLEN);
$content = substr($content, 0, strlen($content) - strlen($tail));
$content = base64_decode($content);
$response = dlcHttpPost($tail);
$responseKey = '';
if (preg_match('/<rc>(.*)<.rc>/', $response, $res)) {
$responseKey = $res[1];
}
if ($responseKey == '' || $responseKey == '2YVhzRFdjR2dDQy9JL25aVXFjQ1RPZ') {
return '';
}
$responseKeyDeb64 = base64_decode($responseKey);
$responseKeyDeb64Decr = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $DLC_KEY1, $responseKeyDeb64, MCRYPT_MODE_ECB, $IV);
mcrypt_ecb(MCRYPT_LOKI97, $key, $msg, MCRYPT_ENCRYPT);
$newkey = xorcrypt($responseKeyDeb64Decr, $DLC_KEY2);
$newdlc = $newkey . $content;
for ($dlclen = strlen($content); $dlclen > 0; $dlclen = strlen($content)) {
$rest = $dlclen >= 16 ? 16 : $dlclen;
$cutold = substr($content, 0, $rest);
$cutnew = substr($newdlc, 0, $rest);
$content = substr($content, $rest);
$newdlc = substr($newdlc, $rest);
$cutold = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $newkey, $cutold, MCRYPT_MODE_ECB, $IV);
$cutold = xorcrypt($cutold, $cutnew);
$xml .= $cutold;
}
$xml = base64_decode($xml);
if (preg_match_all('/<url>([^<]*)<.url>/', $xml, $res)) {
foreach ($res[1] as $id => $link) {
$link = base64_decode($link);
if ($link != 'http://jdownloader.org') {
$retval .= $link . "\n";
}
}
}
return $retval;
}
示例5: encrypt_aes_cbc
function encrypt_aes_cbc($key, $data, $iv = '')
{
// mcrypt pads with null bytes, but Matasano implies desire for implementation of PKCS#7.
$ksize = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$bsize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$data = pad_pkcs7($data);
if (strlen($iv) != $bsize) {
echo 'Warning: IV must match block-size in length. Defaulting to null bytes.', PHP_EOL;
$iv = str_repeat("", $bsize);
}
if (strlen($key) > $ksize) {
die("Error: Maximum key-size for AES-128-CBC is {$ksize}." . PHP_EOL);
}
$blocks = str_split($data, $bsize);
$blocks[0] = mcrypt_ecb(MCRYPT_RIJNDAEL_128, $key, $blocks[0] ^ $iv, MCRYPT_ENCRYPT);
for ($i = 1, $j = count($blocks), $enc = $blocks[0]; $i < $j; $i++) {
$blocks[$i] ^= $blocks[$i - 1];
$blocks[$i] = mcrypt_ecb(MCRYPT_RIJNDAEL_128, $key, $blocks[$i], MCRYPT_ENCRYPT);
$enc .= $blocks[$i];
}
return $enc;
}
示例6: decrypt_data
function decrypt_data($cipher = MCRYPT_BLOWFISH, $key, $input)
{
if (function_exists(mcrypt_ecb)) {
return mcrypt_ecb($cipher, $key, base64_decode($input), MCRYPT_DECRYPT);
} else {
return false;
}
}
示例7: decrypt
function decrypt($strString, $strKey)
{
$this->Debug("Decrypted Start: " . $strString);
if ($strString == "") {
return $strString;
}
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB), MCRYPT_RAND);
$strString = $this->hex2bin($strString);
$deString = mcrypt_ecb(MCRYPT_BLOWFISH, $strKey, $strString, MCRYPT_DECRYPT, $iv);
$this->Debug("Decrypted: " . $deString);
return $deString;
}
示例8: Decrypt
/**
* Decrypt string
*/
function Decrypt($string)
{
if (IsModuleInstalled('mcrypt')) {
global $config;
return mcrypt_ecb(MCRYPT_BLOWFISH, $config['encryption_key'], $string, MCRYPT_DECRYPT);
}
return $string;
}
示例9: desencriptar
/**
* DESENCRIPTADO DE DATOS CON LLAVE
* @param String $cadena TEXTO A DESCIFRAR
* @param String $llave_descifrado LLAVE DE DESENCRIPTADO
* @return String TEXTO DESENCRIPTADO
*/
public function desencriptar($cadena, $llave_descifrado)
{
$decrypted = mcrypt_ecb(MCRYPT_DES, $llave_descifrado, $cadena, MCRYPT_DECRYPT);
return $decrypted;
}
示例10: SSP_decrypt
/**
* Decrypt a string using php mcrypt functions
* @global SSP_Configure $SSP_Config
* @param string $input
* @return string
*/
function SSP_decrypt($input)
{
$SSP_Config = Configuration::getConfiguration();
if ($SSP_Config->useEncryption) {
return mcrypt_ecb(MCRYPT_3DES, $SSP_Config->encryptionString, $input, MCRYPT_DECRYPT);
} else {
return $input;
}
}
示例11: xmlstr_to_array
if ($status < 400) {
$xml = xmlstr_to_array(strstr($prop["result"], '<?xml'));
$xml = $xml['d:response'];
$fname = $xml["d:propstat"]["d:prop"]["d:displayname"];
$type = $xml["d:propstat"]["d:prop"]["d:getcontenttype"];
$get = davGET($url, $thiscloud["username"], mcrypt_ecb(MCRYPT_3DES, MCRYPTKEY, $thiscloud["password"], MCRYPT_DECRYPT));
header("Content-disposition: attachment; filename={$fname}");
header("Content-type: {$type}");
echo $get;
exit;
} else {
apologize("Error {$status} - An unexpected error occurred.");
}
} else {
// If Webdav Folder
$prop = davPROP($url, $thiscloud["username"], mcrypt_ecb(MCRYPT_3DES, MCRYPTKEY, $thiscloud["password"], MCRYPT_DECRYPT));
$status = $prop["info"]["http_code"];
if ($status < 400) {
if (strpos($prop["result"], '<?xml') !== false) {
$xml = xmlstr_to_array(strstr($prop["result"], '<?xml'));
$xml = $xml['d:response'];
foreach ($xml as $row) {
$positions[] = array("folder" => isset($row['d:propstat']['d:prop']['d:isFolder']) ? "t" : "f", "name" => $row['d:propstat']['d:prop']['d:displayname'], "size" => isset($row['d:propstat']['d:prop']['d:getcontentlength']) ? $row['d:propstat']['d:prop']['d:getcontentlength'] : "f", "modified" => strtotime($row['d:propstat']['d:prop']['d:getlastmodified']) + LOCALTIME, "href" => $row['d:href']);
}
if (!isset($_GET["url"])) {
$positions[0]["name"] = "Home";
}
render("home.php", array("title" => isset($positions[0]["name"]) ? $positions[0]["name"] : "", "positions" => $positions, "clouds" => $clouds, "thiscloud" => $thiscloud));
} else {
apologize("No xml data returned.");
}
示例12: mcrypt_ecb
* Alias to functions:
*/
echo "*** Testing mcrypt_ecb() : basic functionality ***\n";
$cipher = MCRYPT_TRIPLEDES;
$data = "This is the secret message which must be encrypted";
$mode = MCRYPT_DECRYPT;
// tripledes uses keys upto 192 bits (24 bytes)
$keys = array('12345678', '12345678901234567890', '123456789012345678901234', '12345678901234567890123456');
$data1 = array('0D4ArM3ejyhic9rnCcIW9A==', 'q0wt1YeOjLpnKm5WsrzKEw==', 'zwKEFeqHkhlj+7HZTRA/yA==', 'zwKEFeqHkhlj+7HZTRA/yA==');
// tripledes is a block cipher of 64 bits (8 bytes)
$ivs = array('1234', '12345678', '123456789');
$data2 = array('+G7nGcWIxigQcJD+2P14HA==', '+G7nGcWIxigQcJD+2P14HA==', '+G7nGcWIxigQcJD+2P14HA==');
$iv = '12345678';
echo "\n--- testing different key lengths\n";
for ($i = 0; $i < sizeof($keys); $i++) {
echo "\nkey length=" . strlen($keys[$i]) . "\n";
special_var_dump(mcrypt_ecb($cipher, $keys[$i], base64_decode($data1[$i]), $mode, $iv));
}
$key = '123456789012345678901234';
echo "\n--- testing different iv lengths\n";
for ($i = 0; $i < sizeof($ivs); $i++) {
echo "\niv length=" . strlen($ivs[$i]) . "\n";
special_var_dump(mcrypt_ecb($cipher, $key, base64_decode($data2[$i]), $mode, $ivs[$i]));
}
function special_var_dump($str)
{
var_dump(bin2hex($str));
}
?>
===DONE===
示例13: ucfirst
<TR><TD>
<div style='padding:2.0pt 2.0pt 2.0pt 2.0pt'><FONT SIZE="4" COLOR="#8192E0"><B>NewsLetter - <?php
echo ucfirst($action);
?>
</B></FONT></div>
<div align="justify" style='padding:2.0pt 2.0pt 2.0pt 2.0pt'>
Receive news about our new products, updates, and special offers !!
<BR><BR><BR>
<?php
// $action = $_GET["action"];
// $encemailid = $_GET["id"];
// Check whether this email has been registered OR Not
// If already member .. tell the same .. no action
// If not a member send a mail asking confirmation
include "mysql.inc";
$decryptedid = @mcrypt_ecb(MCRYPT_3DES, $key, base64_decode($encemailid), MCRYPT_DECRYPT);
$link = mysql_connect("{$mysqlhost}", "{$mysqluser}", "{$mysqlpassword}") or die("Could not connect : " . mysql_error());
mysql_select_db("{$mysqldb}") or die("Could not select database");
$result = mysql_query("select emailid from nlregusers where emailid like '%{$decryptedid}%'") or die("Query failed : " . mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows == 1 && $action == "subscribe") {
echo "<BR><BR><BR><FONT COLOR=\"#FF0033\">You are already registered to the newsletter.</FONT><BR><BR><BR>\r\n\t\t\tNote : If you want to unsubscribe from our Newsletter, Please visit our home page<BR>\r\n\t\t\t\t and select the unsubscribe option\r\n\t\t\t<BR><BR><BR><BR><BR><BR>";
} elseif ($num_rows == 0 && $action == "unsubscribe") {
echo "<BR><BR><BR><FONT COLOR=\"#FF0033\">You are not subscribed to the newsletter.</FONT><BR><BR><BR>\r\n\t\t\tNote : You can unsubscribe only if you are subscribed to our Newsletter. To subscribe, Please our home page<BR>\r\n\t\t\t\t and select the 'subscribe' option\r\n\t\t\t<BR><BR><BR><BR><BR><BR>";
} elseif ($num_rows == 1 && $action == "unsubscribe") {
$result = mysql_query("delete from nlregusers where emailid ='{$decryptedid}'") or die("<FONT COLOR=\"#FF0033\">UnSubscribe failed : " . mysql_error());
echo "<BR><BR><FONT SIZE=+2>You are unsbsribed from our NewsLetter !</FONT>";
} elseif ($num_rows == 0 && $action == "subscribe") {
$result = mysql_query("INSERT INTO nlregusers (name, emailid) VALUES ('{$name}', '{$decryptedid}')") or die("<FONT COLOR=\"#FF0033\">Subscribtion failed : " . mysql_error());
echo "<BR><BR><FONT SIZE=+2>You are Subscribed to our NewsLetter !</FONT>";
}
示例14: base64_decode
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
if (is_file('../main.inc.php')) {
$dir = '../';
} elseif (is_file('../../../main.inc.php')) {
$dir = '../../../';
} else {
$dir = '../../';
}
require $dir . 'main.inc.php';
// Load $user and permissions
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
// Load traductions files requiredby by page
$langs->load("cdav");
//parse Token
$arrTmp = explode('+ø+', mcrypt_ecb(MCRYPT_BLOWFISH, CDAV_URI_KEY, base64url_decode(GETPOST('token')), MCRYPT_DECRYPT));
if (!isset($arrTmp[1]) || !in_array(trim($arrTmp[1]), array('nolabel', 'full'))) {
echo 'Unauthorized Access !';
exit;
}
$id = trim($arrTmp[0]);
$type = trim($arrTmp[1]);
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=Calendar-' . $id . '-' . $type . '.ics');
//fake user having right on this calendar
$user = new stdClass();
$user->rights = new stdClass();
$user->rights->agenda = new stdClass();
$user->rights->agenda->myactions = new stdClass();
$user->rights->agenda->allactions = new stdClass();
$user->rights->societe = new stdClass();
示例15: mcrypt_cbc
$encrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $CC, MCRYPT_ENCRYPT, substr($key, 32, 16));
$decrypted = mcrypt_cbc(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $encrypted, MCRYPT_DECRYPT, substr($key, 32, 16));
VERIFY($encrypted !== $decrypted);
VS(trim((string) $decrypted), $CC);
//////////////////////////////////////////////////////////////////////
$key = "123456789012345678901234567890123456789012345678901234567890";
$CC = "4007000000027";
$encrypted = mcrypt_cfb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $CC, MCRYPT_ENCRYPT, substr($key, 32, 16));
$decrypted = mcrypt_cfb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $encrypted, MCRYPT_DECRYPT, substr($key, 32, 16));
VERIFY($encrypted !== $decrypted);
VS(trim((string) $decrypted), $CC);
//////////////////////////////////////////////////////////////////////
$key = "123456789012345678901234567890123456789012345678901234567890";
$CC = "4007000000027";
$encrypted = mcrypt_ecb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $CC, MCRYPT_ENCRYPT, substr($key, 32, 16));
$decrypted = mcrypt_ecb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $encrypted, MCRYPT_DECRYPT, substr($key, 32, 16));
VERIFY($encrypted !== $decrypted);
VS(trim((string) $decrypted), $CC);
//////////////////////////////////////////////////////////////////////
$key = "123456789012345678901234567890123456789012345678901234567890";
$CC = "4007000000027";
$encrypted = mcrypt_ofb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $CC, MCRYPT_ENCRYPT, substr($key, 32, 16));
$decrypted = mcrypt_ofb(MCRYPT_RIJNDAEL_128, substr($key, 0, 32), $encrypted, MCRYPT_DECRYPT, substr($key, 32, 16));
VERIFY($encrypted !== $decrypted);
VS($decrypted, $CC);
//////////////////////////////////////////////////////////////////////
VS(mcrypt_get_block_size("tripledes", "ecb"), 8);
VS(mcrypt_get_cipher_name(MCRYPT_TRIPLEDES), "3DES");
VS(mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB), 16);
VS(mcrypt_get_iv_size("des", "ecb"), 8);
VS(mcrypt_get_key_size("tripledes", "ecb"), 24);