Exemplo n.º 1
0
int main(void){
	const char 			message[] = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
	uint32_t 			hash[SHA1_HASH_NB_DWORD];
	struct sha1State 	state;

	sha1_init(&state);
	sha1_feed(&state, (const uint32_t*)message, strlen(message));
	sha1_hash(&state, hash);

	printf("Plaintext: \"%s\"\n", message);
	printf("SHA1 hash: ");
	fprintBuffer_raw(stdout, (char*)hash, SHA1_HASH_NB_BYTE);
	putchar('\n');

	return EXIT_SUCCESS;
}
Exemplo n.º 2
0
void sha1_update (SHA1Schedule *ctx, char const *buf, unsigned int len)
{
  register unsigned int i = 0 ;
  for (; i < len ; i++) sha1_feed(ctx, (unsigned char)buf[i]) ;
}