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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:14:06+00:00 2026-06-17T11:14:06+00:00

I am trying to figure out why my Python client and the Ruby server

  • 0

I am trying to figure out why my Python client and the Ruby server are having a disagreement about how to encrypt data. The only difference I see in the Ruby code and my code is that they are not specifying the Initialization Vector, therefore its falling back to the default of all \x0’s

When I try to instantiate PyCrypto without the iv it gives me an error. Here is an example:

from Crypto.Cipher import AES
test = "Very, very confidential data"
key = b'Thirty Two Byte key, made Beef y' 

gryp = AES.new(key, AES.MODE_CBC)

(This example is essentially the example code from the PyCrypto docs without specifying the IV) The docs say w/r/t the IV ” It is optional and when not present it will be given a default value of all zeroes.” However I get the error “ValueError: IV must be 16 bytes long”.

So I could specify the IV, that is not the problem pre se, but I am trying to figure out that if it thinks it cannot use the default, if there is something else wrong with the way I am using the library.

  • 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-17T11:14:08+00:00Added an answer on June 17, 2026 at 11:14 am

    This appears to be an error in the class documentation for Pycrypto’s AES, as the AES implementation has been changed so that the IV is not optional for those modes that require one (i.e. you will have to pass 16 bytes of zeroes yourself, if that is how you want to do it).

    See this bug report for the same issue where someone didn’t specify an IV and looked up the online docs. There was a change that explicitly requires the IV and essentially, nobody has updated the online docs to reflect this. The class docs in the Pycrypto source were updated, but the online documentation needs to be regenerated to reflect this.

    The new documentation from the source states:

    For all other modes, it must be block_size bytes longs.

    Instead of the old version’s

    For all other modes, it must be block_size bytes longs. It is optional and
    when not present it will be given a default value of all zeroes.

    The updated example in the source, which specifies iv, is:

    from Crypto.Cipher import AES
    from Crypto import Random
    
    key = b'Sixteen byte key'
    iv = Random.new().read(AES.block_size)
    cipher = AES.new(key, AES.MODE_CFB, iv)
    msg = iv + cipher.encrypt(b'Attack at dawn')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out the difference between Google's GData API ( http://code.google.com/p/gdata-python-client/
I was trying to figure out which integers python only instantiates once (-6 to
I am having difficulty trying to figure out a bug in my Python (2.7)
I'm trying to figure out Python lambdas. Is lambda one of those "interesting" language
I am trying to figure out how to get a json output in python
I'm trying to figure out how to parse a VCard to a Python dictionary
I am very new to Python, and trying to figure out how to create
I'm trying to setup python fabric for postgresql, but can't figure out how to
I'm trying to figure out the python lxml api, but am running into a
New to Python and trying to figure out what went wrong here. Making a

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.