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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:35:53+00:00 2026-06-06T23:35:53+00:00

I need to encrypt a string using a salt and a key to match

  • 0

I need to encrypt a string using a salt and a key to match a java encryption so that the 3rd party provider can decrypt the values on the other side.

I have tried several StackOverflow articles as I am no expert in encryption and just cannot get the same encryption string using SALT and KEY as the 3rd party provider.

I need to know which encryption type and mode in C# to use to match java’s AES encryptions as used here

https://gist.github.com/ca958d5921d47c4c0a0f

  • 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-06T23:35:54+00:00Added an answer on June 6, 2026 at 11:35 pm

    OK – I figured it out even though it’s cheating to a degree. Because I could not find any encryption technique that would match the plain AES encryption provided by the 3rd party I asked them to change it to

    Cipher cipher = Cipher.getInstance(“AES/CBC/PKCS5Padding”);

    With this I amended my C# code and finally got the integration working:

    public static string Encrypt2(string plainText)
        {
            string PassPhrase = "somepassphrase";
            string SaltValue = "somesalt";
            int PasswordIterations = 0; //amend to match java encryption iteration
            string InitVector = "someiv";
            int KeySize = 0; //amend to match java encryption key size
    
            byte[] initVectorBytes = Encoding.ASCII.GetBytes(InitVector);
            byte[] saltValueBytes = Encoding.ASCII.GetBytes(SaltValue);
    
            byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
    
            Rfc2898DeriveBytes password = new Rfc2898DeriveBytes(
                                                            PassPhrase,
                                                            saltValueBytes,
                                                            PasswordIterations);
    
            byte[] keyBytes = password.GetBytes(KeySize / 8);
            RijndaelManaged symmetricKey = new RijndaelManaged();
            symmetricKey.Mode = CipherMode.CBC;
    
            ICryptoTransform encryptor = symmetricKey.CreateEncryptor(
                                                             keyBytes,
                                                             initVectorBytes);
            MemoryStream memoryStream = new MemoryStream();
    
            CryptoStream cryptoStream = new CryptoStream(memoryStream,
                                                         encryptor,
                                                         CryptoStreamMode.Write);
    
            cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
            cryptoStream.FlushFinalBlock();
            byte[] cipherTextBytes = memoryStream.ToArray();
    
            memoryStream.Close();
            cryptoStream.Close();
    
            string cipherText = Convert.ToBase64String(cipherTextBytes);
    
            return cipherText;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to encrypt a string using MySQL's AES_ENCRYPT function, then attach that encrypted
I need to encrypt string in my app using RSA key from file .key.
in function need key to encrypt string without mcrypt libraly in php function encrypt($str,
I need to encrypt & decrypt data with both Java (on Android) and SJCL
I have a query string I need to encrypt using AES in CBC mode
Here are my requirements: I need to encrypt a string in PHP using AES
I need to encrypt a text string in a .net application using a known
I need to encrypt a string using an RSA 1.5 algorithm. I have been
I am working on a project that is using a Java service to encrypt
For a project I'm working on, I need to encrypt and decrypt a string

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.