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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:41:21+00:00 2026-05-23T12:41:21+00:00

I have a tricky situation here. I have a web service written in C#

  • 0

I have a tricky situation here. I have a web service written in C# and it returns JSON stuff encrypted with the methods described below. This web service is consumed by a Java client, but I’m not able to get my string decrypted in client side, I’ve tried several Java examples of Java functions using DES algorithm but no luck since I always got this error:

java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.decodeBase64

(My environment is Eclipse, jdk1.6.0_26, Android 2.1update emulator)

Please help!!

My C# functions are:

/// <summary>
/// 
/// </summary>
/// <param name="stringToEncrypt"></param>
/// <returns></returns>
public static string Encrypt(string stringToEncrypt)
{
        try
        {
                const string key1 = "MY KEY HERE";

                byte[] iv = { Convert.ToByte("1"), Convert.ToByte("4"), Convert.ToByte("6"), Convert.ToByte("8"), Convert.ToByte("0"), Convert.ToByte("2"), Convert.ToByte("4"), Convert.ToByte("8") };

                byte[] key = Encoding.UTF8.GetBytes(key1);

                var des = new DESCryptoServiceProvider();
                byte[] inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt);
                var ms = new MemoryStream();
                var cs = new CryptoStream(ms, des.CreateEncryptor(key, iv), CryptoStreamMode.Write);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                return Convert.ToBase64String(ms.ToArray());
        }
        catch (Exception ex)
        {
                Logger.Write(new ExceptionLogEntry(ex.ToString()));
        }

        return null;
}

/// <summary>
/// 
/// </summary>
/// <param name="stringToDecrypt"></param>
/// <returns></returns>
public static string Decrypt(string stringToDecrypt)
{
        try
        {
                const string key1 = "MY KEY HERE";

                byte[] iv = { Convert.ToByte("1"), Convert.ToByte("4"), Convert.ToByte("6"), Convert.ToByte("8"), Convert.ToByte("0"), Convert.ToByte("2"), Convert.ToByte("4"), Convert.ToByte("8") };

                byte[] key = Encoding.UTF8.GetBytes(key1);

                var des = new DESCryptoServiceProvider();
                byte[] inputByteArray = Convert.FromBase64String(stringToDecrypt);
                var ms = new MemoryStream();
                var cs = new CryptoStream(ms, des.CreateDecryptor(key, iv), CryptoStreamMode.Write);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                var encoding = Encoding.UTF8;
                return encoding.GetString(ms.ToArray());
        }
        catch(Exception ex)
        {
                Logger.Write(new ExceptionLogEntry(ex.ToString()));
                return "-1";
        }
}

My Java function using commons-codec-1.5.jar is:

KeySpec ks = new DESKeySpec("MY KEY HERE".getBytes("UTF-8"));
SecretKey key = SecretKeyFactory.getInstance("DES").generateSecret(ks);
IvParameterSpec iv = new IvParameterSpec(Hex.decodeHex("1234567890ABCDEF".toCharArray()));
Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key, iv);

byte[] decoded = cipher.doFinal(Base64.decodeBase64("MY ENCRYPTED STRING HERE"));

Log.e(TAG, "DECODED->" + new String(decoded, "UTF-8"));

But I always got this error:

07-05 04:48:20.822: ERROR/AndroidRuntime(1270): java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.decodeBase64

  • 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-23T12:41:21+00:00Added an answer on May 23, 2026 at 12:41 pm

    This error:

    java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.decodeBase64
    

    shows that the problem isn’t (necessarily) in your code at all – it can’t find Base64.decodeBase64, so you’re probably not deploying the Apache Commons Codec library properly. (Admittedly it’s not exactly the error I’d have expected to see, but I’m more used to desktop Java than Android.)

    However, you might as well use Android’s built-in Base64 class instead of working out why you couldn’t get Apache Commons Codec to work.

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

Sidebar

Related Questions

I have a tricky CSS situation here. Basically I have nested span tags that
I have just run myself into this tricky situation. I have an entity called
I have a particularly tricky situation here. I am supporting an java based packaged
Here I have a tricky situation, I guess. I need to be able to
Here is very tricky situation i have tried many things but cant figure it
I have worked myself into a tricky situation and find myself unable to fight
I have what I think is a tricky question, but hopefully someone on here
This is a little tricky so bear with me: I have a PHP script
I have a situation where I user IoC (WindsorContainer) in a .Net web application,
I have looked around here to see if somebody has asked this question before

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.