• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the License); you may
5  *  not use this file except in compliance with the License.
6  *
7  *  http://www.apache.org/licenses/LICENSE-2.0
8  */
9 
10 
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <gmssl/sm3.h>
15 
16 
main(int argc,char ** argv)17 int main(int argc, char **argv)
18 {
19 	SM3_CTX sm3_ctx;
20 	uint8_t buf[4096];
21 	ssize_t len;
22 	uint8_t dgst[32];
23 	int i;
24 
25 	sm3_init(&sm3_ctx);
26 	while ((len = fread(buf, 1, sizeof(buf), stdin)) > 0) {
27 		sm3_update(&sm3_ctx, buf, len);
28 	}
29 	sm3_finish(&sm3_ctx, dgst);
30 
31 	for (i = 0; i < sizeof(dgst); i++) {
32 		printf("%02x", dgst[i]);
33 	}
34 	printf("\n");
35 	return 0;
36 }
37