我有一个如下所示的代码。这里的代码是如果word_size = 64
. 以类似的方式,我也需要 32 和 16。我找不到encrypt
为所有尺寸重用相同功能的方法。此外,我还需要根据word_size声明变量,即。使用uint_16
or or uint_32
oruint_64
取决于 word_size。在这种情况下,你能帮我写一个可重用的代码吗?
#include<stdio.h>
#include<stdint.h>
void encrypt(uint64_t* , uint64_t*, uint64_t*);
int main(){
int block_size;
// Get the user inputs
printf("input the block size: \n");
scanf("%d", &block_size); // can be 32, 64 or 128
int word_size = block_size/2; // 16,32 or 64
// Depending on the word_size, I should declare the variables with
// corresponding width
uint64_t plain_text[2] = {0,0};
uint64_t cipher_text[2] = {0,0};
uint64_t key_text[2] = {0,0};
uint64_t * pt, *ct, *k;
encrypt(pt, ct,k);
}
/*
* Ecnryption Method
*/
void encrypt(uint64_t* pt, uint64_t* ct, uint64_t* k){
// Involves bit shifting algorithm which works only on exact sizes i.e eiter 16,32 or 64.
}
如果需要,我可以提供更多信息。