mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-14 01:53:41 +08:00
Add SM2 demos
This commit is contained in:
22
demos/sm2/sm2_private_key_demo.c
Normal file
22
demos/sm2/sm2_private_key_demo.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmssl/sm2.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
SM2_KEY sm2_key;
|
||||
char *password = "123456";
|
||||
|
||||
if (sm2_key_generate(&sm2_key) != 1) {
|
||||
fprintf(stderr, "error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sm2_private_key_info_encrypt_to_pem(&sm2_key, password, stdout) != 1) {
|
||||
fprintf(stderr, "error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user