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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:07:13+00:00 2026-06-07T23:07:13+00:00

I am banging my head to the wall. I have the following Perl code,

  • 0

I am banging my head to the wall.

I have the following Perl code, and I am trying to do this in .NET without success:

    my $cipher = Crypt::CBC->new(
            -iv => $iv,
            -literal_key => 1,
            -key => $key,
            -cipher => "Crypt::OpenSSL::AES",
            -blocksize => length($iv),
            -keysize => length($key),
            -header => "none"
            );

my .net code is:

byte[] iv = new byte[] { 0x01,..... };
byte[] key = new byte[] { 0x01..... };

            RijndaelManaged aes = new RijndaelManaged();
            aes.Key = key;
            aes.IV = iv;

encryptStringToBytes_AES("bla bla bla", aes.KEY, aes.IV)

...
static byte[] encryptStringToBytes_AES(string plainText, byte[] Key, byte[] IV)
        {
            // Check arguments.
            if (plainText == null || plainText.Length <= 0)
                throw new ArgumentNullException("plainText");
            if (Key == null || Key.Length <= 0)
                throw new ArgumentNullException("Key");
            if (IV == null || IV.Length <= 0)
                throw new ArgumentNullException("Key");

            // Declare the stream used to encrypt to an in memory
            // array of bytes.
            MemoryStream msEncrypt = null;

            // Declare the RijndaelManaged object
            // used to encrypt the data.
            RijndaelManaged aesAlg = null;

            try
            {
                // Create a RijndaelManaged object
                // with the specified key and IV.
                aesAlg = new RijndaelManaged();
                aesAlg.Key = Key;
                aesAlg.IV = IV;

                // Create a decrytor to perform the stream transform.
                ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);

                // Create the streams used for encryption.
                msEncrypt = new MemoryStream();
                using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                {
                    using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                    {

                        //Write all data to the stream.
                        swEncrypt.Write(plainText);
                    }
                }

            }
            finally
            {
                // Clear the RijndaelManaged object.
                if (aesAlg != null)
                    aesAlg.Clear();
            }

            // Return the encrypted bytes from the memory stream.
            return msEncrypt.ToArray();

        }

What am i doing wrong???

Thanks!

  • 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-07T23:07:16+00:00Added an answer on June 7, 2026 at 11:07 pm

    Try with this:

    UnicodeEncoding UE = new UnicodeEncoding();
    byte[] bfr;
    byte[] pwdBits = UE.GetBytes(plainText);
    byte[] result;
    
    int extends = (1 + (pwdBits.Length / 16)) * 16;
    bfr = new byte[extends];
    
    pwdBits.CopyTo(bfr, 0);
    
    using (MemoryStream msCrypt = new MemoryStream())
    {
        RijndaelManaged RMCrypto = new RijndaelManaged();
        RMCrypto.Padding = PaddingMode.PKCS7;
        using (ICryptoTransform encriptor = RMCrypto.CreateEncryptor(Key, IV))
        {
             using (CryptoStream cs = new CryptoStream(msCrypt, encriptor, CryptoStreamMode.Write))
             {
                  cs.Write(bfr, 0, bfr.Length);
                  cs.FlushFinalBlock();
                  result = msCrypt.ToArray();
                  cs.Close();
             }
             msCrypt.Close();
        }
    }
    return result;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been banging my head against the wall trying to figure out this
I have been banging my head against the wall with this odd behaviour on
I have been banging my head on a wall with this one. I need
I've been banging my head against a wall with this code all morning and
I'm banging my head against a wall with this one. I have raphael js
I've been banging my head against the wall on this one. I have a
I have been banging my head against the wall trying to get Exscript installed.
I am banging my head on the wall trying to understand this. See the
Okay, I've been banging my head against the wall with this one. I have
I have been banging my head of the wall for two days with this

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.