LibGCrypt Examples

Rüdiger Sonderfeld cplusplushelp@gmx.net
Wed, 17 Apr 2002 23:07:46 +0200


>         gcry_control( GCRYCTL_INIT_SECMEM, 16384, 0 );

now I get this message

Warning: using insecure memory!
#include <gcrypt.h>
#include <stdio.h>

int main(int argc,char **argv)
{
  GCRY_MD_HD md5;
  FILE *fd;
  unsigned char buffer[500];
  size_t len;
  int a;

  if(argc<2)
  {
    fprintf(stderr,"usage: %s <file>\n",*argv);
    return 1;
  }
  if( (fd=fopen(*(argv+1),"r")) ==NULL)
  {
    perror("Couldn't open file!\n");
    return 1;
  }

  gcry_control( GCRYCTL_INIT_SECMEM, 16384, 0 );
  md5=gcry_md_open(GCRY_MD_MD5,GCRY_MD_FLAG_HMAC);
  if( (len=fread(buffer,sizeof(unsigned char),500,fd)) ==0)
 Hûÿ¿Èøš