导航:首页 > 源码编译 > aes16能不能输出源码

aes16能不能输出源码

发布时间:2023-05-17 19:41:28

① 使用C/C++语言,将DES/AES加密算法,用代码实现

哎,学校大作业吧。核心是des和aes的算法呗,自己一点点写代码量不很少呢。没时间给你写了。
不过有个很好的偷懒办法:建议lz你去找一下OpenSSL的源码。里面有AES,DES的原生C实现。现成函数。lz你直接从里面抠出来复制到你工程里就行了。。

② 加密技术02-对称加密-AES原理

AES 全称 Advanced Encryption Standard(高级加密标准)。它的出现主要是为了取代 DES 加密算法的,因为 DES 算法的密钥长度是 56 位,因此算法的理论安全强度是 2^56。但二十世纪中后期正是计算机飞速发展的阶段,元器件制造工艺的进步使得计算机的处理能力越来越强,所以还是不能满足人们对安全性的要求。于是 1997 年 1 月 2 号,美国国家标准技术研究所宣布什望征集高级加密标准,用以取代 DES。AES 也得到了全世界很多密码工作者的响应,先后有很多人提交了自己设计的算法。最终有5个候选算法进入最后一轮:Rijndael,Serpent,Twofish,RC6 和 MARS。最终经过安全性分析、软硬件性能评估等严格的步骤,Rijndael 算法获胜。

AES 密码与分组密码 Rijndael 基本上完全一致,Rijndael 分组大小和密钥大小都可以为 128 位、192 位和 256 位。然而 AES 只要求分组大小为 128 位,因此只有分组长度为 128 位的 Rijndael 才称为 AES 算法。本文只对分组大小 128 位,密钥长度也为 128 位的 Rijndael 算法进行分析。密钥长度为 192 位和 256 位的处理方式和 128 位的处理方式类似,只不过密钥长度每增加 64 位,算法的循环次数就增加 2 轮,128 位循环 10 轮、192 位循环 12 轮、256 位循环 14 轮。

给定一个 128 位的明文和一个 128 位的密钥,输出一个 128 位的密文。这个密文可以用相同的密钥解密。虽然 AES 一次只能加密 16 个字节,但我们只需要把明文划分成每 16 个字节一组的块,就可以实现任意长度明文的加密。如果明文长度不是 16 个字节的倍数,则需要填充,目前填充方式主要是 PKCS7 / PKCS5。

下来主要分析 16 个字节的加解密过程,下图是 AES 算法框架。

密钥生成流程

G 函数

关于轮常量的生成下文会介绍。

主要作用:一是增加密钥编排中的非线性;二是消除AES中的对称性。这两种属性都是抵抗某些分组密码攻击必要的。

接下来详细解释一下几个关键步骤。

明文矩阵和当前回次的子密钥矩阵进行异或运算。

字节代换层的主要功能是通过 S 盒完成一个字节到另外一个字节的映射。

依次遍历 4 * 4 的明文矩阵 P 中元素,元素高四位值为行号,低四位值为列号,然后在 S 盒中取出对应的值。

行位移操作最为简单,它是用来将输入数据作为一个 4 * 4 的字节矩阵进行处理的,然后将这个矩阵的字节进行位置上的置换。ShiftRows 子层属于 AES 手动的扩散层,目的是将单个位上的变换扩散到影响整个状态当,从而达到雪崩效应。它之所以称作行位移,是因为它只在 4 * 4 矩阵的行间进行操作,每行 4 字节的数据。在加密时,保持矩阵的第一行不变,第二行向左移动 1 个字节、第三行向左移动 2 个字节、第四行向左移动 3 个字节。

列混淆层是 AES 算法中最为复杂的部分,属于扩散层,列混淆操作是 AES 算法中主要的扩散元素,它混淆了输入矩阵的每一列,使输入的每个字节都会影响到 4 个输出字节。行位移层和列混淆层的组合使得经过三轮处理以后,矩阵的每个字节都依赖于 16 个明文字节成可能。其实质是在有限域 GF(2^8) 上的多项式乘法运算,也称伽罗瓦域上的乘法。

伽罗瓦域

伽罗瓦域上的乘法在包括加/解密编码和存储编码中经常使用,AES 算法就使用了伽罗瓦域 GF(2^8) 中的运算。以 2^n 形式的伽罗瓦域来说,加减法都是异或运算,乘法相对较复杂一些,下面介绍 GF(2^n) 上有限域的乘法运算。

本原多项式: 域中不可约多项式,是不能够进行因子分解的多项式,本原多项式是一种特殊的不可约多项式。当一个域上的本原多项式确定了,这个域上的运算也就确定了,本原多项式一般通过查表可得,同一个域往往有多个本原多项式。通过将域中的元素化为多项式的形式,可以将域上的乘法运算转化为普通的多项式乘法模以本原多项式的计算。比如 g(x) = x^3+x+1 是 GF(2^3) 上的本原多项式,那么 GF(2^3) 域上的元素 3*7 可以转化为多项式乘法:

乘二运算: 无论是普通计算还是伽罗瓦域上运算,乘二计算是一种非常特殊的运算。普通计算在计算机上通过向高位的移位计算即可实现,伽罗瓦域上乘二也不复杂,一次移位和一次异或即可。从多项式的角度来看,伽罗瓦域上乘二对应的是一个多项式乘以 x,如果这个多项式最高指数没有超过本原多项式最高指数,那么相当于一次普通计算的乘二计算,如果结果最高指数等于本原多项式最高指数,那么需要将除去本原多项式最高项的其他项和结果进行异或。

比如:GF(2^8)(g(x) = x^8 + x^4 + x^3 + x^2 + 1)上 15*15 = 85 计算过程。

15 写成生成元指数和异或的形式 2^3 + 2^2 + 2^1 + 1,那么:

乘二运算计算过程:

列混淆 :就是把两个矩阵的相乘,里面的运算,加法对应异或运算,乘法对应伽罗瓦域 GF(2^8) 上的乘法(本原多项式为:x^8 + x^4 + x^3 + x^1 + 1)。

Galois 函数为伽罗瓦域上的乘法。

解码过程和 DES 解码类似,也是一个逆过程。基本的数学原理也是:一个数进行两次异或运算就能恢复,S ^ e ^ e = S。

密钥加法层

通过异或的特性,再次异或就能恢复原数。

逆Shift Rows层

恢复 Shift Rows层 的移动。

逆Mix Column层

通过乘上正矩阵的逆矩阵进行矩阵恢复。

一个矩阵先乘上一个正矩阵,然后再乘上他的逆矩阵,相当于没有操作。

逆字节代换层

通过再次代换恢复字节代换层的代换操作。

比如:0x00 字节的置换过程

轮常量生成规则如下:

算法原理和 AES128 一样,只是每次加解密的数据和密钥大小为 192 位和 256 位。加解密过程几乎是一样的,只是循环轮数增加,所以子密钥个数也要增加,最后轮常量 RC 长度增加。

③ 求AES算法加密C语言完整程序

恰好我有。能运行的,C语言的。

#include <string.h>
#include "aes.h"
#include "commonage.h"

#define byte unsigned char

#define BPOLY 0x1b //!< Lower 8 bits of (x^8+x^4+x^3+x+1), ie. (x^4+x^3+x+1).
#define BLOCKSIZE 16 //!< Block size in number of bytes.

#define KEYBITS 128 //!< Use AES128.
#define ROUNDS 10 //!< Number of rounds.
#define KEYLENGTH 16 //!< Key length in number of bytes.

byte xdata block1[ 256 ]; //!< Workspace 1.
byte xdata block2[ 256 ]; //!< Worksapce 2.

byte xdata * powTbl; //!< Final location of exponentiation lookup table.
byte xdata * logTbl; //!< Final location of logarithm lookup table.
byte xdata * sBox; //!< Final location of s-box.
byte xdata * sBoxInv; //!< Final location of inverse s-box.
byte xdata * expandedKey; //!< Final location of expanded key.

void CalcPowLog( byte * powTbl, byte * logTbl )
{
byte xdata i = 0;
byte xdata t = 1;

do {
// Use 0x03 as root for exponentiation and logarithms.
powTbl[i] = t;
logTbl[t] = i;
i++;

// Muliply t by 3 in GF(2^8).
t ^= (t << 1) ^ (t & 0x80 ? BPOLY : 0);
} while( t != 1 ); // Cyclic properties ensure that i < 255.

powTbl[255] = powTbl[0]; // 255 = '-0', 254 = -1, etc.
}

void CalcSBox( byte * sBox )
{
byte xdata i, rot;
byte xdata temp;
byte xdata result;

// Fill all entries of sBox[].
i = 0;
do {
// Inverse in GF(2^8).
if( i > 0 ) {
temp = powTbl[ 255 - logTbl[i] ];
} else {
temp = 0;
}

// Affine transformation in GF(2).
result = temp ^ 0x63; // Start with adding a vector in GF(2).
for( rot = 0; rot < 4; rot++ ) {
// Rotate left.
temp = (temp<<1) | (temp>>7);

// Add rotated byte in GF(2).
result ^= temp;
}

// Put result in table.
sBox[i] = result;
} while( ++i != 0 );
}

void CalcSBoxInv( byte * sBox, byte * sBoxInv )
{
byte xdata i = 0;
byte xdata j = 0;

// Iterate through all elements in sBoxInv using i.
do {
// Search through sBox using j.
cleardog();
do {
// Check if current j is the inverse of current i.
if( sBox[ j ] == i ) {
// If so, set sBoxInc and indicate search finished.
sBoxInv[ i ] = j;
j = 255;
}
} while( ++j != 0 );
} while( ++i != 0 );
}

void CycleLeft( byte * row )
{
// Cycle 4 bytes in an array left once.
byte xdata temp = row[0];
row[0] = row[1];
row[1] = row[2];
row[2] = row[3];
row[3] = temp;
}

void InvMixColumn( byte * column )
{
byte xdata r0, r1, r2, r3;

r0 = column[1] ^ column[2] ^ column[3];
r1 = column[0] ^ column[2] ^ column[3];
r2 = column[0] ^ column[1] ^ column[3];
r3 = column[0] ^ column[1] ^ column[2];

column[0] = (column[0] << 1) ^ (column[0] & 0x80 ? BPOLY : 0);
column[1] = (column[1] << 1) ^ (column[1] & 0x80 ? BPOLY : 0);
column[2] = (column[2] << 1) ^ (column[2] & 0x80 ? BPOLY : 0);
column[3] = (column[3] << 1) ^ (column[3] & 0x80 ? BPOLY : 0);

r0 ^= column[0] ^ column[1];
r1 ^= column[1] ^ column[2];
r2 ^= column[2] ^ column[3];
r3 ^= column[0] ^ column[3];

column[0] = (column[0] << 1) ^ (column[0] & 0x80 ? BPOLY : 0);
column[1] = (column[1] << 1) ^ (column[1] & 0x80 ? BPOLY : 0);
column[2] = (column[2] << 1) ^ (column[2] & 0x80 ? BPOLY : 0);
column[3] = (column[3] << 1) ^ (column[3] & 0x80 ? BPOLY : 0);

r0 ^= column[0] ^ column[2];
r1 ^= column[1] ^ column[3];
r2 ^= column[0] ^ column[2];
r3 ^= column[1] ^ column[3];

column[0] = (column[0] << 1) ^ (column[0] & 0x80 ? BPOLY : 0);
column[1] = (column[1] << 1) ^ (column[1] & 0x80 ? BPOLY : 0);
column[2] = (column[2] << 1) ^ (column[2] & 0x80 ? BPOLY : 0);
column[3] = (column[3] << 1) ^ (column[3] & 0x80 ? BPOLY : 0);

column[0] ^= column[1] ^ column[2] ^ column[3];
r0 ^= column[0];
r1 ^= column[0];
r2 ^= column[0];
r3 ^= column[0];

column[0] = r0;
column[1] = r1;
column[2] = r2;
column[3] = r3;
}

byte Multiply( unsigned char num, unsigned char factor )
{
byte mask = 1;
byte result = 0;

while( mask != 0 ) {
// Check bit of factor given by mask.
if( mask & factor ) {
// Add current multiple of num in GF(2).
result ^= num;
}

// Shift mask to indicate next bit.
mask <<= 1;

// Double num.
num = (num << 1) ^ (num & 0x80 ? BPOLY : 0);
}

return result;
}

byte DotProct( unsigned char * vector1, unsigned char * vector2 )
{
byte result = 0;

result ^= Multiply( *vector1++, *vector2++ );
result ^= Multiply( *vector1++, *vector2++ );
result ^= Multiply( *vector1++, *vector2++ );
result ^= Multiply( *vector1 , *vector2 );

return result;
}

void MixColumn( byte * column )
{
byte xdata row[8] = {
0x02, 0x03, 0x01, 0x01,
0x02, 0x03, 0x01, 0x01
}; // Prepare first row of matrix twice, to eliminate need for cycling.

byte xdata result[4];

// Take dot procts of each matrix row and the column vector.
result[0] = DotProct( row+0, column );
result[1] = DotProct( row+3, column );
result[2] = DotProct( row+2, column );
result[3] = DotProct( row+1, column );

// Copy temporary result to original column.
column[0] = result[0];
column[1] = result[1];
column[2] = result[2];
column[3] = result[3];
}

void SubBytes( byte * bytes, byte count )
{
do {
*bytes = sBox[ *bytes ]; // Substitute every byte in state.
bytes++;
} while( --count );
}

void InvSubBytesAndXOR( byte * bytes, byte * key, byte count )
{
do {
// *bytes = sBoxInv[ *bytes ] ^ *key; // Inverse substitute every byte in state and add key.
*bytes = block2[ *bytes ] ^ *key; // Use block2 directly. Increases speed.
bytes++;
key++;
} while( --count );
}

void InvShiftRows( byte * state )
{
byte temp;

// Note: State is arranged column by column.

// Cycle second row right one time.
temp = state[ 1 + 3*4 ];
state[ 1 + 3*4 ] = state[ 1 + 2*4 ];
state[ 1 + 2*4 ] = state[ 1 + 1*4 ];
state[ 1 + 1*4 ] = state[ 1 + 0*4 ];
state[ 1 + 0*4 ] = temp;

// Cycle third row right two times.
temp = state[ 2 + 0*4 ];
state[ 2 + 0*4 ] = state[ 2 + 2*4 ];
state[ 2 + 2*4 ] = temp;
temp = state[ 2 + 1*4 ];
state[ 2 + 1*4 ] = state[ 2 + 3*4 ];
state[ 2 + 3*4 ] = temp;

// Cycle fourth row right three times, ie. left once.
temp = state[ 3 + 0*4 ];
state[ 3 + 0*4 ] = state[ 3 + 1*4 ];
state[ 3 + 1*4 ] = state[ 3 + 2*4 ];
state[ 3 + 2*4 ] = state[ 3 + 3*4 ];
state[ 3 + 3*4 ] = temp;
}

void ShiftRows( byte * state )
{
byte temp;

// Note: State is arranged column by column.

// Cycle second row left one time.
temp = state[ 1 + 0*4 ];
state[ 1 + 0*4 ] = state[ 1 + 1*4 ];
state[ 1 + 1*4 ] = state[ 1 + 2*4 ];
state[ 1 + 2*4 ] = state[ 1 + 3*4 ];
state[ 1 + 3*4 ] = temp;

// Cycle third row left two times.
temp = state[ 2 + 0*4 ];
state[ 2 + 0*4 ] = state[ 2 + 2*4 ];
state[ 2 + 2*4 ] = temp;
temp = state[ 2 + 1*4 ];
state[ 2 + 1*4 ] = state[ 2 + 3*4 ];
state[ 2 + 3*4 ] = temp;

// Cycle fourth row left three times, ie. right once.
temp = state[ 3 + 3*4 ];
state[ 3 + 3*4 ] = state[ 3 + 2*4 ];
state[ 3 + 2*4 ] = state[ 3 + 1*4 ];
state[ 3 + 1*4 ] = state[ 3 + 0*4 ];
state[ 3 + 0*4 ] = temp;
}

void InvMixColumns( byte * state )
{
InvMixColumn( state + 0*4 );
InvMixColumn( state + 1*4 );
InvMixColumn( state + 2*4 );
InvMixColumn( state + 3*4 );
}

void MixColumns( byte * state )
{
MixColumn( state + 0*4 );
MixColumn( state + 1*4 );
MixColumn( state + 2*4 );
MixColumn( state + 3*4 );
}

void XORBytes( byte * bytes1, byte * bytes2, byte count )
{
do {
*bytes1 ^= *bytes2; // Add in GF(2), ie. XOR.
bytes1++;
bytes2++;
} while( --count );
}

void CopyBytes( byte * to, byte * from, byte count )
{
do {
*to = *from;
to++;
from++;
} while( --count );
}

void KeyExpansion( byte * expandedKey )
{
byte xdata temp[4];
byte i;
byte xdata Rcon[4] = { 0x01, 0x00, 0x00, 0x00 }; // Round constant.

unsigned char xdata *key;
unsigned char xdata a[16];
key=a;
//以下为加解密密码,共16字节。可以选择任意值
key[0]=0x30;
key[1]=0x30;
key[2]=0x30;
key[3]=0x30;
key[4]=0x30;
key[5]=0x30;
key[6]=0x30;
key[7]=0x30;
key[8]=0x30;
key[9]=0x30;
key[10]=0x30;
key[11]=0x30;
key[12]=0x30;
key[13]=0x30;
key[14]=0x30;
key[15]=0x30;
////////////////////////////////////////////

// Copy key to start of expanded key.
i = KEYLENGTH;
do {
*expandedKey = *key;
expandedKey++;
key++;
} while( --i );

// Prepare last 4 bytes of key in temp.
expandedKey -= 4;
temp[0] = *(expandedKey++);
temp[1] = *(expandedKey++);
temp[2] = *(expandedKey++);
temp[3] = *(expandedKey++);

// Expand key.
i = KEYLENGTH;
while( i < BLOCKSIZE*(ROUNDS+1) ) {
// Are we at the start of a multiple of the key size?
if( (i % KEYLENGTH) == 0 ) {
CycleLeft( temp ); // Cycle left once.
SubBytes( temp, 4 ); // Substitute each byte.
XORBytes( temp, Rcon, 4 ); // Add constant in GF(2).
*Rcon = (*Rcon << 1) ^ (*Rcon & 0x80 ? BPOLY : 0);
}

// Keysize larger than 24 bytes, ie. larger that 192 bits?
#if KEYLENGTH > 24
// Are we right past a block size?
else if( (i % KEYLENGTH) == BLOCKSIZE ) {
SubBytes( temp, 4 ); // Substitute each byte.
}
#endif

// Add bytes in GF(2) one KEYLENGTH away.
XORBytes( temp, expandedKey - KEYLENGTH, 4 );

// Copy result to current 4 bytes.
*(expandedKey++) = temp[ 0 ];
*(expandedKey++) = temp[ 1 ];
*(expandedKey++) = temp[ 2 ];
*(expandedKey++) = temp[ 3 ];

i += 4; // Next 4 bytes.
}
}

void InvCipher( byte * block, byte * expandedKey )
{
byte round = ROUNDS-1;
expandedKey += BLOCKSIZE * ROUNDS;

XORBytes( block, expandedKey, 16 );
expandedKey -= BLOCKSIZE;

do {
InvShiftRows( block );
InvSubBytesAndXOR( block, expandedKey, 16 );
expandedKey -= BLOCKSIZE;
InvMixColumns( block );
} while( --round );

InvShiftRows( block );
InvSubBytesAndXOR( block, expandedKey, 16 );
}

void Cipher( byte * block, byte * expandedKey ) //完成一个块(16字节,128bit)的加密
{
byte round = ROUNDS-1;

XORBytes( block, expandedKey, 16 );
expandedKey += BLOCKSIZE;

do {
SubBytes( block, 16 );
ShiftRows( block );
MixColumns( block );
XORBytes( block, expandedKey, 16 );
expandedKey += BLOCKSIZE;
} while( --round );

SubBytes( block, 16 );
ShiftRows( block );
XORBytes( block, expandedKey, 16 );
}

void aesInit( unsigned char * tempbuf )
{
powTbl = block1;
logTbl = block2;
CalcPowLog( powTbl, logTbl );

sBox = tempbuf;
CalcSBox( sBox );

expandedKey = block1; //至此block1用来存贮密码表
KeyExpansion( expandedKey );

sBoxInv = block2; // Must be block2. block2至此开始只用来存贮SBOXINV
CalcSBoxInv( sBox, sBoxInv );
}

//对一个16字节块解密,参数buffer是解密密缓存,chainBlock是要解密的块
void aesDecrypt( unsigned char * buffer, unsigned char * chainBlock )
{
//byte xdata temp[ BLOCKSIZE ];

//CopyBytes( temp, buffer, BLOCKSIZE );
CopyBytes(buffer,chainBlock,BLOCKSIZE);
InvCipher( buffer, expandedKey );
//XORBytes( buffer, chainBlock, BLOCKSIZE );
CopyBytes( chainBlock, buffer, BLOCKSIZE );
}

//对一个16字节块完成加密,参数buffer是加密缓存,chainBlock是要加密的块
void aesEncrypt( unsigned char * buffer, unsigned char * chainBlock )
{
CopyBytes( buffer, chainBlock, BLOCKSIZE );
//XORBytes( buffer, chainBlock, BLOCKSIZE );
Cipher( buffer, expandedKey );
CopyBytes( chainBlock, buffer, BLOCKSIZE );
}

//加解密函数,参数为加解密标志,要加解密的数据缓存起始指针,要加解密的数据长度(如果解密运算,必须是16的整数倍。)
unsigned char aesBlockDecrypt(bit Direct,unsigned char *ChiperDataBuf,unsigned char DataLen)
{
unsigned char xdata i;
unsigned char xdata Blocks;
unsigned char xdata sBoxbuf[256];
unsigned char xdata tempbuf[16];
unsigned long int xdata OrignLen=0; //未加密数据的原始长度

if(Direct==0)
{
*((unsigned char *)&OrignLen+3)=ChiperDataBuf[0];
*((unsigned char *)&OrignLen+2)=ChiperDataBuf[1];
*((unsigned char *)&OrignLen+1)=ChiperDataBuf[2];
*((unsigned char *)&OrignLen)=ChiperDataBuf[3];
DataLen=DataLen-4;
}
else
{
memmove(ChiperDataBuf+4,ChiperDataBuf,DataLen);
OrignLen=DataLen;
ChiperDataBuf[0]=OrignLen;
ChiperDataBuf[1]=OrignLen>>8;
ChiperDataBuf[2]=OrignLen>>16;
ChiperDataBuf[3]=OrignLen>>24;
}
cleardog();
aesInit(sBoxbuf); //初始化
if(Direct==0) //解密
{
Blocks=DataLen/16;
for(i=0;i<Blocks;i++)
{
cleardog();
aesDecrypt(tempbuf,ChiperDataBuf+4+16*i);
}
memmove(ChiperDataBuf,ChiperDataBuf+4,OrignLen);
cleardog();
return(OrignLen);
}
else //加密
{
if(DataLen%16!=0)
{
Blocks=DataLen/16+1;
//memset(ChiperDataBuf+4+Blocks*16-(DataLen%16),0x00,DataLen%16); //不足16字节的块补零处理
}
else
{
Blocks=DataLen/16;
}

for(i=0;i<Blocks;i++)
{
cleardog();
aesEncrypt(tempbuf,ChiperDataBuf+4+16*i);
}
cleardog();
return(Blocks*16+4);
}

}

//#endif
以上是C文件。以下是头文件

#ifndef AES_H
#define AES_H

extern void aesInit( unsigned char * tempbuf );
extern void aesDecrypt(unsigned char *buffer, unsigned char *chainBlock);
extern void aesEncrypt( unsigned char * buffer, unsigned char * chainBlock );

extern void aesInit( unsigned char * tempbuf );
extern void aesDecrypt( unsigned char * buffer, unsigned char * chainBlock );
extern void aesEncrypt( unsigned char * buffer, unsigned char * chainBlock );

extern unsigned char aesBlockDecrypt(bit Direct,unsigned char *ChiperDataBuf,unsigned char DataLen);

#endif // AES_H

这是我根据网上程序改写的。只支持128位加解密。没有使用占内存很多的查表法。故运算速度会稍慢。

④ 前端使用CryptoJS AES加密 ,后端php解密问题

PHP7.1 已经不能用mcrypt了,所以我用的是openssl_encrypt和openssl_decrypt。

<?php
$data="ThisisanAEScryptdemo.";
$privateKey="";//KEY16字节用aes-128-cbc,32字节用aes-256-cbc
$iv="4490d2ded4f2d4ad";//AES的IV是16个字节

//加密
//$encrypted=openssl_encrypt($data,'aes-128-cbc',$privateKey,0,$iv);
$encrypted=openssl_encrypt($data,'aes-256-cbc',$privateKey,0,$iv);
echo$encrypted,PHP_EOL;

//解密
$encryptedData=$encrypted;
//$decrypted=openssl_decrypt($encryptedData,'aes-128-cbc',$privateKey,0,$iv);
$decrypted=openssl_decrypt($encryptedData,'aes-256-cbc',$privateKey,0,$iv);
echo($decrypted);

输出结果如下:

EPcMQRXA53/hRkPyILFI4fF/9sW2X53tLiDT26khNsA=
ThisisanAEScryptdemo.

⑤ 我有一个AES128加密算法,16字节明文+16字节密钥输入,16字节密文输出,如果1K的数据加密后输出多大

既然有算法,自己试一下不就知道了?16字节就是128位,AES是按128位分组加密,你说应该输出是多少呢?呵呵

阅读全文

与aes16能不能输出源码相关的资料

热点内容
银河v10驱动重编译 浏览:889
电脑上文件夹右击就会崩溃 浏览:689
右美维持算法 浏览:938
php基础编程教程pdf 浏览:219
穿越之命令与征服将军 浏览:351
android广播重复 浏览:832
像阿里云一样的服务器 浏览:318
水冷空调有压缩机吗 浏览:478
访问日本服务器可以做什么 浏览:432
bytejava详解 浏览:448
androidjava7 浏览:384
服务器在山洞里为什么还有油 浏览:885
天天基金app在哪里下载 浏览:974
服务器软路由怎么做 浏览:292
冰箱压缩机出口 浏览:228
OPT最佳页面置换算法 浏览:644
网盘忘记解压码怎么办 浏览:853
文件加密看不到里面的内容 浏览:654
程序员脑子里都想什么 浏览:434
oppp手机信任app在哪里设置 浏览:189