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 3355644
In Process

The Archive Base Latest Questions

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

I have few questions about this code: <?php $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv =

  • 0

I have few questions about this code:

<?php 
   $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); 
   $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); 
   $key = "This is a very secret key"; 
   $text = file_get_contents('path/to/your/file'); 
   echo strlen($text) . "\n"; 

   $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); 
   file_put_contents('path/to/your/file', $crypttext);    
?> 

It encrypts the file just fine, however it adds additional nulls at the end, so if I encrypt:

 a test string is this one
    and here is a new line 

once decrypted becomes:

a test string is this one
    and here is a new line 000000000000000

What’s going on?

Second, is MCRYPT_RIJNDAEL_256 compatible with AES-128?

Finally, how would I let another party decrypt a file I’ve encrypted? They would need to know which encryption was used and I am not sure what to tell them.

  • 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-18T02:25:12+00:00Added an answer on May 18, 2026 at 2:25 am

    MCRYPT_RIJNDAEL_128 is AES-128, MCRYPT_RIJNDAEL_256 is AES-256 – just another name:

    […]The standard comprises three block
    ciphers, AES-128, AES-192 and AES-256,
    adopted from a larger collection
    originally published as Rijndael.originally published as Rijndael.[…]

    […]The Rijndael cipher was developed by
    two Belgian cryptographers, Joan
    Daemen and Vincent Rijmen, and
    submitted by them to the AES selection
    process. Rijndael (pronounced “Rhine
    dall”) is a wordplay with the names of
    the two inventors.[…]

    The \x00 characters you encounter at the end of the decrypted string are the padding required for some block ciphers (with ECB being such a block cipher). Mcyrpt uses NULL-padding internally if the input data needs to be padded to the required block length. There are other padding modes available (which have to be user-coded when using Mcyrpt), namely PKCS7, ANSI X.923 or ISO 10126. NULL-padding is problematic when encrypting binary data that may end with one or more \x00 characters because you can’t detect where the data ends and the padding starts – the other padding modes mentioned solve this kind of problem. If you’re encrypting character data (strings) you can easily trim off the trailing \x00 by using $data = trim($data, "\x00");.

    To decrypt the data you sent to a consumer, the consumer would need to know the IV (initialization vector) ($iv), the algorithm used (MCRYPT_RIJNDAEL_256/AES-256), the encryption mode (ECB), the secret encryption key ($key) and the padding mode used (NULL-padding). The IV can be transmitted with the encrypted data as it does not need to be kept secret:

    The IV must be known to the recipient
    of the encrypted information to be
    able to decrypt it. This can be
    ensured in a number of ways: by
    transmitting the IV along with the
    ciphertext, by agreeing on it
    beforehand during the key exchange or
    the handshake, by calculating it
    (usually incrementally), or by
    measuring such parameters as current
    time (used in hardware authentication
    tokens such as RSA SecurID, VASCO
    Digipass, etc.), IDs such as sender’s
    and/or recipient’s address or ID, file
    ID, the packet, sector or cluster
    number, etc. A number of variables can
    be combined or hashed together,
    depending on the protocol.depending on the protocol.

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

Sidebar

Related Questions

I have a few questions about data synchronization. The architecture does not seem to
I've been hearing about triggers, and I have a few questions. What are triggers?
I've discovered this folder in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and have a few questions. What
I have a few basic questions about the Dispose Pattern in C#. In the
There have been a few questions regarding this issue before; my understanding is that
I have a few specific questions about web services (SOAP over HTTP): A client
I have a few questions related: 1) Is possible to make my program change
Ok, have a bunch of questions that I have been thinking about the past
I'm in the process of learning about simulated annealing algorithms and have a few
I'm a newbie to pgsql. I have few questionss on it: 1) I know

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.