01,4F,64,1E,80,20,01,7E如何存储到数组里
时间: 2023-09-08 14:12:20 浏览: 38
这个问题涉及到数组的类型和编程语言,不同的语言有不同的数据类型和数组定义方式。假设你是在使用C语言,那么这个数组可以定义为一个unsigned char类型的数组,如下所示:
```
unsigned char arr[] = {0x01, 0x4F, 0x64, 0x1E, 0x80, 0x20, 0x01, 0x7E};
```
这个数组的每个元素都是一个8位的无符号整数,对应着这个16进制数列中的每一个数。你可以通过下标来访问这个数组的每个元素,比如arr[0]表示第一个元素0x01。
相关问题
aes二维数组S盒查表代码
以下是AES二维数组S盒查表的代码示例:
```c
#include <stdio.h>
int main() {
unsigned char s_box[16][16] = {
{0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76},
{0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0},
{0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15},
{0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75},
{0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84},
{0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf},
{0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8},
{0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2},
{0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73},
{0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb},
{0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79},
{0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08},
{0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a},
{0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e},
{0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf},
{0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16}
};
int row = 5; // S盒中的行数
int col = 10; // S盒中的列数
printf("S-Box value for row %d and column %d is: 0x%x\n", row, col, s_box[row][col]);
return 0;
}
```
在上面的代码中,我们定义了一个16x16的二维数组`s_box`,用于存储AES中的S盒。然后我们可以通过指定S盒中的行和列来查找对应的值。在这个例子中,我们输出了S盒中第5行第10列的值。
使用c#分别生成 4维,5维,6维数组(分别为int类型,double类型,string类型)(每个花括号里都有随机的数值) 并且遍历数组
以下是分别生成 4维、5维、6维数组的示例代码:
```csharp
// 生成 int 类型的 4 维数组
int[,,,] intArray4D = new int[2, 3, 4, 5]
{
{
{
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20}
},
{
{21, 22, 23, 24, 25},
{26, 27, 28, 29, 30},
{31, 32, 33, 34, 35},
{36, 37, 38, 39, 40}
},
{
{41, 42, 43, 44, 45},
{46, 47, 48, 49, 50},
{51, 52, 53, 54, 55},
{56, 57, 58, 59, 60}
}
},
{
{
{61, 62, 63, 64, 65},
{66, 67, 68, 69, 70},
{71, 72, 73, 74, 75},
{76, 77, 78, 79, 80}
},
{
{81, 82, 83, 84, 85},
{86, 87, 88, 89, 90},
{91, 92, 93, 94, 95},
{96, 97, 98, 99, 100}
},
{
{101, 102, 103, 104, 105},
{106, 107, 108, 109, 110},
{111, 112, 113, 114, 115},
{116, 117, 118, 119, 120}
}
}
};
// 遍历 int 类型的 4 维数组
for (int i = 0; i < intArray4D.GetLength(0); i++)
{
for (int j = 0; j < intArray4D.GetLength(1); j++)
{
for (int k = 0; k < intArray4D.GetLength(2); k++)
{
for (int l = 0; l < intArray4D.GetLength(3); l++)
{
Console.WriteLine("intArray4D[{0}, {1}, {2}, {3}] = {4}", i, j, k, l, intArray4D[i, j, k, l]);
}
}
}
}
// 生成 double 类型的 5 维数组
double[,,,,] doubleArray5D = new double[2, 3, 4, 5, 2]
{
{
{
{
{1.1, 1.2},
{2.1, 2.2},
{3.1, 3.2},
{4.1, 4.2},
{5.1, 5.2}
},
{
{6.1, 6.2},
{7.1, 7.2},
{8.1, 8.2},
{9.1, 9.2},
{10.1, 10.2}
},
{
{11.1, 11.2},
{12.1, 12.2},
{13.1, 13.2},
{14.1, 14.2},
{15.1, 15.2}
},
{
{16.1, 16.2},
{17.1, 17.2},
{18.1, 18.2},
{19.1, 19.2},
{20.1, 20.2}
}
},
{
{
{21.1, 21.2},
{22.1, 22.2},
{23.1, 23.2},
{24.1, 24.2},
{25.1, 25.2}
},
{
{26.1, 26.2},
{27.1, 27.2},
{28.1, 28.2},
{29.1, 29.2},
{30.1, 30.2}
},
{
{31.1, 31.2},
{32.1, 32.2},
{33.1, 33.2},
{34.1, 34.2},
{35.1, 35.2}
},
{
{36.1, 36.2},
{37.1, 37.2},
{38.1, 38.2},
{39.1, 39.2},
{40.1, 40.2}
}
},
{
{
{41.1, 41.2},
{42.1, 42.2},
{43.1, 43.2},
{44.1, 44.2},
{45.1, 45.2}
},
{
{46.1, 46.2},
{47.1, 47.2},
{48.1, 48.2},
{49.1, 49.2},
{50.1, 50.2}
},
{
{51.1, 51.2},
{52.1, 52.2},
{53.1, 53.2},
{54.1, 54.2},
{55.1, 55.2}
},
{
{56.1, 56.2},
{57.1, 57.2},
{58.1, 58.2},
{59.1, 59.2},
{60.1, 60.2}
}
}
},
{
{
{
{61.1, 61.2},
{62.1, 62.2},
{63.1, 63.2},
{64.1, 64.2},
{65.1, 65.2}
},
{
{66.1, 66.2},
{67.1, 67.2},
{68.1, 68.2},
{69.1, 69.2},
{70.1, 70.2}
},
{
{71.1, 71.2},
{72.1, 72.2},
{73.1, 73.2},
{74.1, 74.2},
{75.1, 75.2}
},
{
{76.1, 76.2},
{77.1, 77.2},
{78.1, 78.2},
{79.1, 79.2},
{80.1, 80.2}
}
},
{
{
{81.1, 81.2},
{82.1, 82.2},
{83.1, 83.2},
{84.1, 84.2},
{85.1, 85.2}
},
{
{86.1, 86.2},
{87.1, 87.2},
{88.1, 88.2},
{89.1, 89.2},
{90.1, 90.2}
},
{
{91.1, 91.2},
{92.1, 92.2},
{93.1, 93.2},
{94.1, 94.2},
{95.1, 95.2}
},
{
{96.1, 96.2},
{97.1, 97.2},
{98.1, 98.2},
{99.1, 99.2},
{100.1, 100.2}
}
},
{
{
{101.1, 101.2},
{102.1, 102.2},
{103.1, 103.2},
{104.1, 104.2},
{105.1, 105.2}
},
{
{106.1, 106.2},
{107.1, 107.2},
{108.1, 108.2},
{109.1, 109.2},
{110.1, 110.2}
},
{
{111.1, 111.2},
{112.1, 112.2},
{113.1, 113.2},
{114.1, 114.2},
{115.1, 115.2}
},
{
{116.1, 116.2},
{117.1, 117.2},
{118.1, 118.2},
{119.1, 119.2},
{120.1, 120.2}
}
}
}
};
// 遍历 double 类型的 5 维数组
for (int i = 0; i < doubleArray5D.GetLength(0); i++)
{
for (int j = 0; j < doubleArray5D.GetLength(1); j++)
{
for (int k = 0; k < doubleArray5D.GetLength(2); k++)
{
for (int l = 0; l < doubleArray5D.GetLength(3); l++)
{
for (int m = 0; m < doubleArray5D.GetLength(4); m++)
{
Console.WriteLine("doubleArray5D[{0}, {1}, {2}, {3}, {4}] = {5}", i, j, k, l, m, doubleArray5D[i, j, k, l, m]);
}
}
}
}
}
// 生成 string 类型的 6 维数组
string[,,,,,] stringArray6D = new string[2, 3, 4, 5, 2, 2]
{
{
{
{
{
{"a1", "a2"},
{"b1", "b2"},
{"c1", "c2"},
{"d1", "d2"},
{"e1", "e2"}
},
{
{"f1", "f2"},
{"g1", "g2"},
{"h1", "h2"},
{"i1", "i2"},
{"j1", "j2"}
},
{
{"k1", "k2"},
{"l1", "l2"},
{"m1", "m2"},
{"n1", "n2"},
{"o1", "o2"}
},
{
{"p1", "p2"},
{"q1", "q2"},
{"r1", "r2"},
{"s1", "s2"},
{"t1", "t2"}
}
},
{
{
{"u1", "u2"},
{"v1", "v2"},
{"w1", "w2"},
{"x1", "x2"},
{"y1", "y2"}
},
{
{"z1", "z2"},
{"A1", "A2"},
{"B1", "B2"},
{"C1", "C2"},
{"D1", "D2"}
},
{
{"E1", "E2"},
{"F1", "F2"},
{"G1", "G2"},
{"H1", "H2"},
{"I1", "I2"}
},
{
{"J1", "J2"},
{"K1", "K2"},
{"L1", "L2"},
{"M1", "M2"},
{"N1", "N2"}
}
},
{
{
{"O1", "O2"},
{"P1", "P2"},
{"Q1", "Q2"},
{"R1", "R2"},
{"S1", "S2"}
},
{
{"T1", "T2"},
{"U1", "U2"},
{"V1", "V2"},
{"W1", "W2"},
{"X1", "X2"}
},
{
{"Y1", "Y2"},
{"Z1", "Z2"},
{"1a", "1b"},
{"2c", "2d"},
{"3e", "3f"}
},
{
{"4g", "4h"},
{"5i", "5j"},
{"6k", "6l"},
{"7m", "7n"},
{"8o", "8p"}
}
}
},
{
{
{
{"9q", "9r"},
{"0s", "0t"},
{"1u", "1v"},
{"2w", "2x"},
{"3y", "3z"}
},
{
{"4A", "4B"},
{"5C", "5D"},
{"6E", "6F"},
{"7G", "7H"},
{"8I", "8J"}
},
{
{"9K", "9L"},
{"0M", "0N"},
{"1O", "1P"},
{"2Q", "2R"},
{"3S", "3T"}
},
{
{"4U", "4V"},
{"5W", "5X"},
{"6Y", "6Z"},
{"7a", "7b"},
{"8c", "8d"}
}
},
{
{
{"9e", "9f"},
{"0g", "0h"},
{"1i", "1j"},
{"2k", "2l"},
{"3m", "3n"}
},
{
{"4o", "4p"},
{"5q", "5r"},
{"6s", "6t"},
{"7u", "7v"},
{"8w", "8x"}
},
{
{"9y", "9z"},
{"0A", "0B"},
{"1C", "1D"},
{"2E", "2F"},
{"3G", "3H"}
},
{
{"4I", "4J"},
{"5K", "5L"},
{"6M", "6N"},
{"7O", "7P"},
{"8Q", "8R"}
}
},
{
{
{"9S", "9T"},
{"0U", "0V"},
{"1W", "1X"},
{"2Y", "2Z"},
{"3a", "3b"}
},
{
{"4c", "4d"},
{"5e", "5f"},
{"6g", "6h"},
{"7i", "7j"},
{"8k", "8l"}
},
{
{"9m", "9n"},
{"0o", "0p"},
{"1q", "1r"},
{"2s", "2t"},
{"3u", "3v"}
},
{
{"4w", "4x"},
{"5y", "5z"},
{"6A", "6B"},
{"7C", "7D"},
{"8E", "8F"}
}
}
}
},
{
{
{
{
{"9G", "9H"},
{"0I", "0J"},
{"1K", "1L"},
{"2M", "2N"},
{"3O", "3P"}
},
{
{"4Q", "4R"},
{"5S", "5T"},
{"6U", "6V"},
{"7W", "7X"},
{"8Y", "8Z"}
},
{
{"9a", "9b"},
{"0c", "0d"},
{"1e", "1f"},
{"2g", "2h"},
{"3i", "3j"}
},
{
{"4k", "4l"},
{"5m", "5n"},
{"6o", "6p"},
{"7q", "7r"},
{"8s", "8t"}
}
},
{
{
{"9u", "9v"},
{"0w", "0x"},
{"1y", "1z"},
{"2A", "2B"},
{"3C", "3D"}
},
{
{"4E", "4F"},
{"5G", "5H"},
{"6I", "6J"},
{"7K", "7L"},
{"8M", "8N"}
},
{
{"9O", "9P"},
{"0Q", "0R"},
{"1S", "1T"},
{"2U", "2V"},
{"3W", "3X"}
},
{
{"4Y", "4Z"},
{"5a", "5b"},
{"6c", "6d"},
{"7e", "7f"},
{"8g", "8h"}
}
},
{
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)