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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:30:45+00:00 2026-05-23T13:30:45+00:00

I have my pre generated AES key what i would like to use in

  • 0

I have my pre generated AES key what i would like to use in C#. Can anybody point me to the right direction how to use pre generated AES key with RijndaelManaged object.

EDIT: I have the key in byte[] array and i need to encrypt a Stream.

I found these code samples online:

    private static byte[] Decrypt(byte[] key, byte[] PGPkey)
    {
        RijndaelManaged rDel = new RijndaelManaged();
        rDel.Key = key;
        //rDel.Mode = CipherMode.ECB; // http://msdn.microsoft.com/en-us/library/system.security.cryptography.ciphermode.aspx
        rDel.Padding = PaddingMode.PKCS7; // better lang support
        ICryptoTransform cTransform = rDel.CreateDecryptor();
        byte[] resultArray = cTransform.TransformFinalBlock(PGPkey, 0, PGPkey.Length);
        return resultArray;
    }

    private static byte[] Encrypt(byte[] key, byte[] PGPkey)
    {
         RijndaelManaged rDel = new RijndaelManaged();
         rDel.Key = key;
         //rDel.Mode = CipherMode.ECB; // http://msdn.microsoft.com/en-us/library/system.security.cryptography.ciphermode.aspx
         rDel.Padding = PaddingMode.PKCS7; // better lang support
         ICryptoTransform cTransform = rDel.CreateEncryptor();
         byte[] resultArray = cTransform.TransformFinalBlock(PGPkey, 0, PGPkey.Length);
         return resultArray;
     }

Im not getting any errors but after decryption the byte array is not the same as it was before going to the ecryption.

EDIT: I think i got it working, had to set the rDel.Mode = CipherMode.ECB;

  • 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-23T13:30:46+00:00Added an answer on May 23, 2026 at 1:30 pm

    If it worked when setting it to ECB mode, that is becuase it was using CBC mode before, which uses a randomly generated Initialization Vector when encrypting. Initialization Vectors randomize the cipher text so two identical peiced of data, encrypted with the same key, dont produce the same cipher text. You can grab the byte[] RijndaelManagedInstance.IV property and store that with your cipher text. Then when decrypting, set the same property to the Initialization Vector used to encrypt, and then you should recieve the same plain text after decryption.

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

Sidebar

Related Questions

I have a number of pre-generated, static xml files containing soap requests. I can
I have a web application written in pure JavaScript (no pre-generated HTML except for
For my palm pre app I have a dynamically generated list (pulling in data
I have a situation where I have quite a few generated functions, and would
I have an app where the client will provide a list of pre-generated codes.
I have a lot of pre-existing BMPs (and our clients have pre-existing bmps as
I have a pre tag within my page that contains quite a bit of
I have a pre-made SQLite database that I am downloading from the net via
I have a couple of pre-existing applications which I need to run in one
I have all my content pre-escaped, so rather than using the triple stash everywhere

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.