小编Coo*_*ude的帖子

如何在C中实现AES加密?

我现在很困惑。我有一个 AES 加密,我将它复制并粘贴到记事本 ++ 中并将其另存为 .c 文件。然后我转到 cygwin 并尝试运行它,它说找不到“包含 aes.h”。我到处都在互联网上搜索过这个问题,除了 SSL 上的某些内容外,它没有给我任何答案。

顺便说一句,我试图编译的代码粘贴在下面

/*
This is an implementation of the AES128 algorithm, specifically ECB and CBC mode.

The implementation is verified against the test vectors in:
  National Institute of Standards and Technology Special Publication 800-38A 2001 ED

ECB-AES128
----------

  plain-text:
    6bc1bee22e409f96e93d7e117393172a
    ae2d8a571e03ac9c9eb76fac45af8e51
    30c81c46a35ce411e5fbc1191a0a52ef
    f69f2445df4f9b17ad2b417be66c3710

  key:
    2b7e151628aed2a6abf7158809cf4f3c

  resulting cipher
    3ad77bb40d7a3660a89ecaf32466ef97 
    f5d3d58503b9699de785895a96fdbaaf 
    43b1cd7f598ece23881b00e3ed030688 
    7b0c785e27e8ad3f8223207104725dd4 


NOTE:   String length must be evenly divisible by 16byte (str_len % 16 == 0)
        You should pad the …
Run Code Online (Sandbox Code Playgroud)

c cygwin compilation aes

3
推荐指数
1
解决办法
3万
查看次数

C中的递归函数

所以下面是我的代码,我在尝试将我的知识用于递归函数时遇到了一些困难.我的程序想要使用用户输入作为最后一个数字来查找所有自然数的总和.

我试图使用递归函数,但它似乎不起作用.在我看来,问题是一旦函数再次调用它自己,整数总和似乎不记得它的初始值.有人可以帮帮我吗.

include <stdio.h>

int sum(int); 

main(){
    int a; 
    printf("Enter your number\n");
    scanf_s("%d", &a); 
    printf("The answer is %d", sum(a)); 
    getch();
}

int sum(int a){ 
    int total = 0;
    total = total + a;  /*add the new value of a*/
    a--;    /*decrease the value of a by one*/
    if (a == 0){
        return total;   /* leave the function and display this value */
    }
    else {
        sum(a); /*call this function again */
    }
}
Run Code Online (Sandbox Code Playgroud)

c variables recursion

1
推荐指数
1
解决办法
138
查看次数

标签 统计

c ×2

aes ×1

compilation ×1

cygwin ×1

recursion ×1

variables ×1