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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:22:57+00:00 2026-06-18T08:22:57+00:00

So I finally found something a little more understable in implementing a AES 128

  • 0

So I finally found something a little more understable in implementing a AES 128 encryption for a .Net Wcf Service with the same encryption. My problem with it now is that whenever it would try to decrypt the string it would have a step where it does a FromBase64String convert which will give me an error:

static public string DecryptString(string message, string key)
{
    string output = "";
    Rijndael aes = new RijndaelManaged();

    try
    {
        byte[] encrypted = Convert.FromBase64String(message);
        byte[] cipherText = GetCipherText(encrypted);

        aes.Key = Convert.FromBase64String(key);
        aes.Mode = CipherMode.CBC;

        aes.IV = GetIV(encrypted);

        using (MemoryStream ms = new MemoryStream())
        {
            using (ICryptoTransform decryptor = aes.CreateDecryptor())
            {
                using (CryptoStream cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Write))
                {
                    cs.Write(cipherText, 0, cipherText.Length);
                    cs.FlushFinalBlock();

                    byte[] decrypted = ms.ToArray();
                    output = Encoding.UTF8.GetString(decrypted);
                }
            }
        }
    }

The error is:

Index was outside the bounds of the array.

and it happens on the

cs.FlushFinalBlock();

This is the encryption that it produced for the message “heythere” and a key of “25f9e794323b453885f5181f1b624d0b”

0suql40BUGiDoFA4SdXJAA==

This is coming from my .Net encryption:

unNWQfm9RaU/HgKlDNEmoXZaTzsuBoTNsA2UvDKZhc4=

PS For the iPhone encryption of AES 128, this is where I got the codes from:

AES interoperability between .Net and iPhone?

  • 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-18T08:22:58+00:00Added an answer on June 18, 2026 at 8:22 am

    Look at AES Keeping your documents secure article on MSDN and scroll down to the section entitled “Using the AES Class”, “Figure 15 Using AES” has a nice and simple example of encryption / decryption.

    P.S. Be aware of padding that is used in certain block cypher (like AES) modes (like CBC), these can be a pain when different systems are talking to each other as padding / block sizes can vary from one system to another… see padding fun

    EDIT: Just spotted this little gem… simple-2-way-encryption-for-c-sharp

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

Sidebar

Related Questions

So I've finally got my WCF service setup and talking to browser via ASP.NET
I happened to something strange to me on CALayer.And finally found the CALayer's frame.size
I've finally found a client for my hosted software - the first time I've
I've finally found a way to debug classic asp code in visual studio 2008
So, I finally found a task where I could make use of the new
I found out recently that JList (finally!) was generified in JDK7. Why JTree and
I am finally asking this question as I have never actually found an answer.
I have two questions. 1) I found a little gem of code for how
Finally found out how to achieve this! Turned out it is as simple as
I'm reviewing some team code and I found something like this : MyObj obj

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.