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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:22:57+00:00 2026-05-17T19:22:57+00:00

I believe when the EnterpriseLibrary tries to decrypt a RijndaelManaged encrypted string it expects

  • 0

I believe when the EnterpriseLibrary tries to decrypt a RijndaelManaged encrypted string it expects the Initialization Vector to be prepended to the encrypted text. Currently with the code below. I can decrypt the message with out an exception, but I am getting weird characters like:

�猀漀椀搀㴀眀最爀甀戀攀㄀☀甀琀挀㴀㈀ ㄀ ⴀ㄀ ⴀ㈀㄀吀㄀㌀㨀㔀㈀㨀㄀㌀

What do I need to do to make this work? Any help is greatly appreciated. Here is some of the code I have…

I have a C# application that decrypts data using the EnterpriseLibrary 4.1 (encryption: RijndaelManaged).

string message = "This encrypted message comes from Java Client";
Cryptographer.DecryptSymmetric("RijndaelManaged", message);

The client encryptes the message, implemented in Java.

public String encrypt(String auth) {
           try {
               String cipherKey = "Key as a HEX string";
               byte[] rawKey = hexToBytes(cipherKey);
               SecretKeySpec keySpec = new SecretKeySpec(rawKey, "AES");
               Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

               String cipherIV = "xYzF5AqA2cKLbvbfGzsMwg==";
               byte[] btCipherIV = Base64.decodeBase64(cipherIV.getBytes());

               cipher.init(Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec (btCipherIV));
               byte[] unencrypted = StringUtils.getBytesUtf16(auth);
               byte[] encryptedData = cipher.doFinal(unencrypted);
               String encryptedText = null;

               byte[] entlib = new byte[btCipherIV2.length + encryptedData.length];
               System.arraycopy(btCipherIV, 0, entlib, 0, btCipherIV.length);
               System.arraycopy(encryptedData, 0, entlib, btCipherIV.length, encryptedData.length);

               encryptedText = new String(encryptedData);
               encryptedText = Base64.encodeBase64String(encryptedData);               
               return encryptedText;

           } catch (Exception e) {
           }

           return "";
       }

    public static byte[] hexToBytes(String str) {
          if (str==null) {
             return null;
          } else if (str.length() < 2) {
             return null;
          } else {
             int len = str.length() / 2;
             byte[] buffer = new byte[len];
             for (int i=0; i<len; i++) {
                 buffer[i] = (byte) Integer.parseInt(
                    str.substring(i*2,i*2+2),16);
             }
             return buffer;
          }

       }
  • 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-17T19:22:57+00:00Added an answer on May 17, 2026 at 7:22 pm

    I found the answer. The problem in the above code:

    StringUtils.getBytesUtf16(auth);
    

    Instead the Enterprise Library is using Little Endian byte order. The function I was using doesn’t. Instead I should have used:

    StringUtils.getBytesUtf16Le(auth);
    

    This solved my problem. Thanks for anyone who took a loot at this. I appreciate it!

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

Sidebar

Related Questions

No related questions found

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.