Thread: Libgcrypt library

  1. #1
    Registered User
    Join Date
    Sep 2015
    Posts
    2

    Question Libgcrypt library

    Hi,

    I am trying to encrypt a message using Libgcrypt library.
    I have written the below code but I am getting an error when I try to declare objects of type 'gcry_cipher_hd_t' that 'Type gcry_cipher_hd_t could not be resolved' when it is defined in the gcrypt.h and I have included it.
    I am in Ubuntu.
    Thanks for any help.

    My code
    Code:
    #include <gcrypt.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <assert.h>
    int main()
    {
        gcry_cipher_hd_t hd;
        gcry_error_t error;
        char msg='Helloo world my first encryption';
        char pwd;
        int algo = 'GCRY_CIPHER_AES256';
        int mode = 'GCRY_CIPHER_MODE_CBC';
        unsigned int flags=0;
        printf('Enter Password');
        scanf("%c", &pwd);
        //GCRY_CIPHER_AES256
        error = gcry_cipher_open(*hd, algo, mode,flags);
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,249
    Quote Originally Posted by hiranava
    I have written the below code but I am getting an error when I try to declare objects of type 'gcry_cipher_hd_t' that 'Type gcry_cipher_hd_t could not be resolved' when it is defined in the gcrypt.h and I have included it.
    Are there any other error messages, e.g., are you sure that the header file was correctly included?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2015
    Posts
    2
    No other errors. Even the function calls to the function in header doesn't show an error.

    If i declare as below it doesn't show a error but I am not sure if that is correct.

    Code:
    #include <gcrypt.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <assert.h>
    int main()
    {
    	struct gcry_cipher_hd_t hd;
    	struct gcry_error_t error;
    	char msg='Helloo world my first encryption';
    	char pwd;
    	int algo = 'GCRY_CIPHER_AES256';
    	int mode = 'GCRY_CIPHER_MODE_CBC';
    	unsigned int flags=0;
    	printf('Enter Password');
    	scanf("%c", &pwd);
    	//GCRY_CIPHER_AES256
    	error = gcry_cipher_open(*hd, algo, mode,flags);
    }

  4. #4
    Registered User FourAngels's Avatar
    Join Date
    Aug 2015
    Location
    Canada
    Posts
    130
    Does the header file exist in the /usr/include directory?

  5. #5
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,671
    Is your password really a single character?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Item Library(business library)
    By LísiasDeCastro in forum C Programming
    Replies: 6
    Last Post: 06-08-2015, 04:53 AM
  2. Problem with libgcrypt
    By Fabrício Lélis in forum C Programming
    Replies: 3
    Last Post: 12-10-2012, 08:03 AM
  3. Replies: 9
    Last Post: 02-08-2012, 10:23 PM
  4. How to decrypt / encrypt using libgcrypt ? (ARC4)
    By jabka in forum C Programming
    Replies: 6
    Last Post: 04-21-2010, 11:34 PM
  5. Replies: 19
    Last Post: 01-12-2006, 11:04 AM