BachelorWork/appendixes/BC_ZK/demoExamples/cryptgenrandom.c
2021-05-28 00:53:37 +02:00

34 lines
956 B
C

/*
Organization: Technical University of Kosice (TUKE),
Department: Department of Electronics and Multimedia Telecommunications (DEMT/KEMT),
Faculties: Faculty of Electrical Engineering and Informatics (FEI),
Feld of study: Informatics,
Study program: Computer Networks,
School year: 3., Bachelor study, 2020/2021,
Author: Marek Rohac -- MR,
Compiler: Winlibs GCC -- MinGW-W64 x86_64-posix-seh, built by Brecht Sanders, v. 10.2.0,
-- also works with GCC 11.1.0
*/
#include<stdio.h>
#include<windows.h>
int main(){
HCRYPTPROV hCryptProv;
BYTE *pbData=(BYTE*)malloc(sizeof(BYTE)* 10);
CryptAcquireContext(&hCryptProv,NULL,
"Microsoft Base Cryptographic Provider v1.0",
PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT);
if(CryptGenRandom(hCryptProv,10,pbData)!=0){
printf("Random sequence generated. \n");
}
else
{
printf("Error during CryptGenRandom.\n");
free(pbData);
return -1;
}
free(pbData);
return 0;
}