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

  • Home
  • SEARCH
  • 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 6551197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:18:22+00:00 2026-05-25T12:18:22+00:00

I am working on linux/ubuntu. I found out that mcrypt is automatically included as

  • 0

I am working on linux/ubuntu. I found out that mcrypt is automatically included as a library in this platform. I want to create an encryption with aes 256 and cbc padding 7 (iv). Could someone please give me an example of how to encrypt a string with aes 256 and cbc iv, padding 7?

Rijndael is the same with aes.!

this is the link i’ve found with the library i would like to use: http://linux.die.net/man/3/mcrypt

  • 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-05-25T12:18:23+00:00Added an answer on May 25, 2026 at 12:18 pm

    Are you asking how to use mcrypt? Here’s a basic skeleton:

    #include <mcrypt.h>
    
    int main()
    {
      char algo[] = "rijndael-256";
      char mode[] = "cbc";
    
      char key[] = ...
      char iv[]  = ...
    
      MCRYPT td = mcrypt_module_open(algo, NULL, mode, NULL);
      if (td == MCRYPT_FAILED) { /* error */ }
    
      int r =  mcrypt_generic_init(td, key, keysize, iv);
    
      /* use  mdecrypt_generic() or mcrypt_generic() */
    
      mcrypt_generic_deinit(td);
    
      mcrypt_module_close(td);
    }
    

    You have to check the actual key size and IV size with mcrypt_enc_get_key_size(td) and mcrypt_enc_get_iv_size(td) and provide suitable key and IV data.


    Edit: Because it’s so simple, here’s an algorithm to add and strip PCKS7 padding:

    std::string add_pkcs7_padding(std::string s, std::size_t n)
    {
      const std::size_t fill = n - (s.length() % n);
      s.append(fill, static_cast<char>(fill));
      return s;
    }
    
    std::string strip_pkcs7_padding(std::string s, std::size_t n)
    {
      const std::size_t pad = static_cast<unsigned char>(*s.rbegin());
      return s.substr(0, s.length() - pad);
    }
    

    (Library-grade code would of course test that n can be represented by a char, and that during stripping the input string is non-empty and the padding is valid.)

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

Sidebar

Related Questions

Iam working on Ubuntu.(Linux) I want to redirect from the page one.php to two.php,
I'm working on Ubuntu.(Linux) I want to display all .php pages to .html in
Working in bash under Linux ubuntu 10 here I have Bash script that reads
I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04)
I am currently running gdb version 6.7.1 on Ubuntu Linux, and working in a
I am working in Linux, Eclipse CDT, g++, with Boost library. Having existing program
I'm trying to get a global hotkey working in Linux using Mono. I found
I am working with a legacy C library that can be extended by writing
I'm trying to install GODI on linux (Ubuntu). It's a library management tool for
I am working on a Linux Ubuntu 8.10 and I would like to install

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.