【问题标题】:Adding salt to sha256 openssl?向 sha256 openssl 添加盐?
【发布时间】:2012-09-03 13:29:27
【问题描述】:

这个简单的代码接受用户输入并将给定字符串的 sha256 打印到标准输出。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/sha.h>

int main()
{
 SHA256_CTX context;
 unsigned char md[SHA256_DIGEST_LENGTH];
 char *input;
 printf("Watta hash: ");
 scanf("%m[^\n]%*c", &input);
 size_t length = strlen((const char*)input);
 int i;
 SHA256_Init(&context);
 SHA256_Update(&context, (unsigned char*)input, length);
 SHA256_Final(md, &context);
 for(i=0; i<SHA256_DIGEST_LENGTH; i++){
   printf("%02x", md[i]);
 }
 printf("\n");
 free(input);
 return 0;
}

我的问题是:如何在这个哈希中添加盐?

【问题讨论】:

    标签: c hash openssl


    【解决方案1】:

    SHA256_Update() 添加第二个调用,其中数据是所需的盐。

    【讨论】:

      猜你喜欢
      • 2011-05-09
      • 2013-09-11
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多