?
Solved

What is the Input vs. Output size in Rijndael Managed cryptography

Posted on 2004-09-13
6
Medium Priority
?
886 Views
Last Modified: 2013-12-03
If I encrypt an X byte string using Rijndael Managed cryptography in C#, what will the output string size be?  From my reading, I would think it would be in 16 byte chunks, because the default blocksize is 128 (bits, I think), but when I encrypt a 16 byte string, I get 44 bytes out.  I did not write the encryption/decryption function I am using, the code is shown below.  Does the size change have to do with the base64 stuff, which I am not clear on either?  Once upon a time in life I thought I knew something, but lately...

public static string Encrypt(string inStr)
{
  System.Security.Cryptography.RijndaelManaged rij = new System.Security.Cryptography.RijndaelManaged();
  rij.Key = thisKey;
  rij.IV = thisIV;
  byte[] inByte = System.Text.Encoding.UTF8.GetBytes(inStr);
  byte[] outByte = rij.CreateEncryptor().TransformFinalBlock(inByte, 0,inByte.Length);
  string encryptStr = Convert.ToBase64String(outByte);
  return encryptStr;
}
public static string Decrypt(string inStr)
{
  System.Security.Cryptography.RijndaelManaged rij = new System.Security.Cryptography.RijndaelManaged();
  rij.Key = thisKey;
  rij.IV = thisIV;
  byte[] inByte = Convert.FromBase64String(inStr);
  byte[] outByte = rij.CreateDecryptor().TransformFinalBlock(inByte, 0,inByte.Length);
  string decryptStr = System.Text.Encoding.UTF8.GetString(outByte);
  return decryptStr;
}

Thank you.

0
Comment
Question by:kevinmackenzie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 12050559
the base64 has a whole lot to do with it ... base64 adds significant size overhead

the encryption also adds a bit but not as significant as the base64.
0
 

Author Comment

by:kevinmackenzie
ID: 12050710
Thanks.  Can you explain the two overheads so that I can predict them?  I will go study base64, but I can find NOTHING that describes the overhead for Rijndael...

Kevin
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 12050870
base64 is roughly 3 times larger.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:kevinmackenzie
ID: 12050909
If you or anyone else can point me to a reference that describes the overhead for base64 and another reference for rijndael, that would make this question answered.

I appreciate the effort, but "roughly" does not get close enough to an answer.

Thanks,

Kevin
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1500 total points
ID: 12051156
sorry its roughly 33% and here is why http://email.about.com/cs/standards/a/base64_encoding.htm you cannot go past roughly because there is header info and it works in blocks of 3.

for a large file no biggie but on say 10 bytes thats a big difference.
0
 

Author Comment

by:kevinmackenzie
ID: 12051326
Thank you, I will split the points, I am still hoping for a reference or answer on the Rijndael overhead.

Kevin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question