blob: 8b9caf4e20218973c23608456b25cd43de7fdfb5 (
plain)
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
|
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "sha256.h"
void libscrypt_salt_gen(uint8_t *rand, size_t len)
{
unsigned char buf[32];
time_t current_time;
char *c_time_string;
SHA256_CTX ctx;
SHA256_Init(&ctx );
current_time = time(NULL);
c_time_string = ctime(¤t_time);
SHA256_Update(&ctx, c_time_string, strlen(c_time_string));
SHA256_Final(buf, &ctx);
memcpy(rand, buf, len);
}
|