Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:35:11+00:00 2026-06-15T04:35:11+00:00

I try to write simple application that fetch string and encrypt it. After I

  • 0

I try to write simple application that fetch string and encrypt it.
After I want to get previous string by using decryption algorithm.

AES encryption/decryption will be pretty good

It seems basic but most examples written in other languages but not C. I didn’t find any appropriate example to do that. Please help.

Any and all suggestions would be greatly appreciated. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:35:12+00:00Added an answer on June 15, 2026 at 4:35 am

    You will need the following libraries:

       libc.lib
      euser.lib
      libcrypto.lib
    

    Also you will need to install openC Plugin from http://www.developer.nokia.com/info/sw.nokia.com/id/91d89929-fb8c-4d66-bea0-227e42df9053/Open_C_SDK_Plug-In.html

    Here is the source code with explanation comments:

    #include <stddef.h>
    #include <openssl/rc4.h>
    #include <openssl/md5.h>
    
    //#include<filelogger.h>
    
    void openc_encrypt(int len, unsigned char* in, unsigned char* crypted, unsigned char* password, int passlen)
    {
       unsigned char digest[MD5_DIGEST_LENGTH];
       RC4_KEY key;
    
       MD5(password, passlen, digest);
    
       RC4_set_key(&key, MD5_DIGEST_LENGTH, digest);
       RC4(&key, len, in, crypted);
    }
    
    void openc_decrypt(int len, unsigned char* in, unsigned char* decrypted, unsigned char* password, int passlen)
    {
       unsigned char digest[MD5_DIGEST_LENGTH];
       RC4_KEY key;
    
       MD5(password, passlen, digest);
    
       RC4_set_key(&key, MD5_DIGEST_LENGTH, digest);
       RC4(&key, len, in, decrypted);
    }
    
    /////////////////////////////////////////////////////////////////////////////////////
    
    const TInt KMaxTextLen = 100;
    
    _LIT8(KExampleText, "Encrypt this text!");
    _LIT8(KPassWord, "secret");
    
    void doExampleL()
        {    
        TBuf8<KMaxTextLen> buffer(KExampleText);
    
        HBufC8* password = KPassWord().AllocLC();    
        HBufC8* crypted = HBufC8::NewLC(buffer.Size());
    
        TPtr8 cryptedPtr = crypted->Des();
        cryptedPtr.SetLength(buffer.Size());
    
        openc_encrypt(buffer.Size(),
                  (unsigned char*)buffer.Ptr(),
                  (unsigned char*)cryptedPtr.Ptr(),
                  (unsigned char*)password->Ptr(),
                  password->Size()); 
    
      //LOGDES16(buffer); //Encrypt this text!
      //LOGDES8(*crypted) ; //Ór›­Â Û¦  }ÖŠ4 b q 
    
        HBufC8* decrypted = HBufC8::NewLC(buffer.Size());
        TPtr8 decryptedPtr = decrypted->Des();
    
        buffer.Copy(cryptedPtr);
        decryptedPtr.SetLength(buffer.Size());
    
        openc_decrypt(buffer.Size(),         
                    (unsigned char*)buffer.Ptr(),
                    (unsigned char*)decryptedPtr.Ptr(),
                    (unsigned char*)password->Ptr(),
                    password->Size());
    
      //LOGDES16(buffer);       //Ór›­Â Û¦  }ÖŠ4 b q 
      //LOGDES8(*decrypted) ; //Encrypt this text!
    
        CleanupStack::PopAndDestroy(3);  //decrypted, crypted, password                   
    }
    

    The text in this example has been encrypted with the pass phrase and after that decrypted with the same pass phrase using the example functions openc_encrypt() and openc_decrypt().

    Edit

    AES Encryption

    (credit goes to:abhi)

    For AES encryption Please refer to this example: http://saju.net.in/code/misc/openssl_aes.c.txt

    The code is detailed enough with comments and if you still need much explanation about the API itself i suggest check out this book Network Security with OpenSSL by Viega/Messier/Chandra (google it you will easily find a pdf of this..) read chapter 6 which is specific to symmetric ciphers using EVP API.. This helped me a lot actually understanding the reasons behind using various functions and structures of EVP.

    and if you want to dive deep into the Openssl crypto library, i suggest download the code from the openssl website (the version installed on your machine) and then look in the implementation of EVP and aeh api implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to write a simple Spring 3 console application. I Cant get this
I try to write simple application using OpenMP. Unfortunately I have problem with speedup.
I want to create simple application that detects language(using Google API) of phrase and
I am trying to write a simple Android application using the NDK and C++.
I am trying to write a simple application that loads images that are stored
I'm trying to write a simple XMPP application on Android using asmack, but I've
I try to write a simple user script to enlarge the picture when you
try to write a composite component that allows mutltiple text inputs. I read that
I try to write Activator action for changing current song rating. I now that
I try to write a macro in clojure that sets up a namespace and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.