相关资料
https://en.wikipedia.org/wiki/Symmetric-key_algorithm
https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
# man enc
对称加密:symmetric-key encryption
Symmetric-key algorithms are algorithms for cryptography that use the same cryptographic keys for both encryption of plaintext and decryption of ciphertext.
Symmetric-key encryption can use either stream ciphers or block ciphers.
常用对称加密算法
DES、AES
加密模式
Electronic Codebook(ECB) 电子密码本
The simplest of the encryption modes is the Electronic Codebook (ECB) mode.
The message is divided into blocks, and each block is encrypted separately.
Cipher Block Chaining(CBC) 密码分组链接
In CBC mode, each block of plaintext is XORed with the previous ciphertext block before being encrypted.
To make each message unique, an initialization vector must be used in the first block.
CBC has been the most commonly used mode of operation. Its main drawbacks are that encryption is sequential (i.e., it cannot be parallelized), and that the message must be padded to a multiple of the cipher block size.
openssl
# openssl des3 -salt -in file.txt -out file.des3
# openssl des3 -d -salt -in file.des3 -out file.txt
# openssl aes-256-cbc -in file.txt -out file.aes
PHP
# openssl_get_cipher_methods
# openssl_encrypt
# openssl_decrypt
密钥生成
你所使用的密钥应该越随机越好,它不能是一个普通的文本字符串,经过哈希函数处理过也不行。
为了生成一个合适的密钥,你应该使用下面提供的 create_key() 方法:
// $key will be assigned a 16-byte (128-bit) random key
$key = create_key(16);
$key = hex2bin($key);
function create_key($length)
{
if (function_exists('random_bytes'))
{
try
{
return random_bytes((int) $length);
}
catch (Exception $e)
{
log_message('error', $e->getMessage());
return FALSE;
}
}
$is_secure = NULL;
$key = openssl_random_pseudo_bytes($length, $is_secure);
return ($is_secure === TRUE) ? $key : FALSE;
}
加密解密
$data = 'hello,world!';
$method = 'aes-128-cbc';
$key = create_key(16);
$iv = ($iv_size = openssl_cipher_iv_length($method)) ? create_key($iv_size) : '';
$cipherText = openssl_encrypt($data,$method,$key,1,$iv);
$plainText = openssl_decrypt($cipherText,$method,$key,1,$iv);
echo base64_encode($cipherText);echo "<br />";echo $plainText;
想想你的文章写的特别好https://www.237fa.com/
文章的确不错啊https://www.cscnn.com/
《塞西亚:复仇之剑》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/22479.html
《闪耀的花火》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/50951.html
《大爸爸,小爸爸和其它故事》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/69254.html
《加油,印度!》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/135335.html
《塞西亚:复仇之剑》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/22479.html
建议补充国内外研究对比,以拓展视野。
新项目准备上线,寻找志同道合的合作伙伴
华纳东方明珠客服微信?(▲18288362750?《?微信STS5099? 】【╃q 2704132802╃】
华纳客服开户流程,华纳客服开户流程图(?183-8890--9465—《?薇-STS5099】
果博东方客服开户联系方式【182-8836-2750—】?薇- cxs20250806】
果博东方公司客服电话联系方式【182-8836-2750—】?薇- cxs20250806】
果博东方开户流程【182-8836-2750—】?薇- cxs20250806】
果博东方客服怎么联系【182-8836-2750—】?薇- cxs20250806】
东方明珠客服开户联系方式【182-8836-2750—】?μ- cxs20250806
东方明珠客服电话联系方式【182-8836-2750—】?- cxs20250806】
东方明珠开户流程【182-8836-2750—】?薇- cxs20250806】
东方明珠客服怎么联系【182-8836-2750—】?薇- cxs20250806】
华纳圣淘沙公司开户新手教程
零基础学会(183-8890-9465薇-STS5099)
华纳圣淘沙公司开户
华纳圣淘沙公司开户保姆级教程(183-8890-9465薇-STS5099)
一步步教你开通华纳圣淘沙公司账户(183-8890-9465薇-STS5099)
华纳圣淘沙公司开户分步图解
首次开户必看:(183-8890-9465薇-STS5099)
华纳圣淘沙全攻略
华纳圣淘沙公司开户实操手册(183-8890-9465薇-STS5099)
华纳圣淘沙开户流程视频教程
手把手教学:(183-8890-9465薇-STS5099)
华纳圣淘沙公司开户
华纳圣淘沙公司开户完全指南(183-8890-9465薇-STS5099)
南黑窑妹子开放时间a0hk.cn