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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:26:03+00:00 2026-06-08T09:26:03+00:00

As a self study exercise, I’m trying to learn how to use some of

  • 0

As a self study exercise, I’m trying to learn how to use some of the pycrypto library. I need to decrypt a ciphertext string in CBC_MODE using AES. I the ciphertext, key, and IV are all given. Here is the code that I have written:

from Crypto.Cipher import AES

mode = AES.MODE_CBC
key = "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1"
ciphertext = "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1";

iv = ciphertext[:32] 
ciphertext = ciphertext[32:] 
decryptor = AES.new(key, mode, iv)
plaintext = decryptor.decrypt(ciphertext)
print plaintext

When I run this, I get the following error:

ValueError: IV must be 16 bytes long

I know that the IV string is 32 hex characters, and therefore 16 bytes. I think that this might be a typing problem, but I don’t know how to correct it. Can anyone help?

Thank you!

  • 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-08T09:26:04+00:00Added an answer on June 8, 2026 at 9:26 am

    Your strings contain only hex characters, but they are still plain strings, so every character counts.

    So your IV string is 32 byte long as you sliced it out from ciphertext.

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

Sidebar

Related Questions

I'm trying to implement Dijkstra's algorithm in Java (self-study). I use the pseudo-code provided
I have been progressing through Learn Prolog Now! as self-study and am now learning
Working on some self study in understanding structures in C. I've made a small
I'm trying to self-study C using C Primer Plus from Stephen Prata and one
I am doing some study on arrays, and I am trying to resolve how
I'm doing Learn C the hard way for self-study coming from knowing a bit
I am trying to self-study both object oriented design and parallel programming using the
i have done self study on learning struts 2. i have used one code
self.mood_scale = { '-30':Panic, '-20':'Fear', '-10':'Concern', '0':'Normal', '10':'Satisfaction', '20':'Happiness', '30':'Euphoria'} I need to set
I'm study iOS development. Now playing with views. I don't use interface builder at

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.