1

I have the encrypted password function at Android java function and Decrypt function at C# side. My problem is when I encrypt the password

Password is
No8ANfBX/0GAWJnF4v0bQwf/4UiJ7qY7rOPfrfB0XMQ=

When I pass this parameter via Rest API, My password changed to-

No8ANfBX/0GAWJnF4v0bQwf\/4UiJ7qY7rOPfrfB0XMQ= Image

So when decrypt at server,password is not same. My code for parameter pass is

public JSONObject A(String userName, String passWord, String version) throws Exception {
    JSONObject result = null;
    JSONObject o = new JSONObject();
    JSONObject p = new JSONObject();
    try {
        o.put("interface", "AA");
        o.put("method", "A");
        p.put("userName", mapObject(userName));
        p.put("passWord", mapObject(passWord));
        p.put("version", mapObject(version));
        o.put("parameters", p);
        Log.e("Pass",String.valueOf(passWord));
        Log.e("Pass",String.valueOf(mapObject(passWord)));
        String s = o.toString();
        Log.e("Params", String.valueOf(s));
        String r = load(s);
        Log.e("Params", String.valueOf(r));
        result = new JSONObject(r);
    } catch (Exception e) {
        Log.e("Error is", String.valueOf(e));
    }
    return result;
}

How could I change not to add extra \ in params?

4
  • 1
    Its just escaping the special character /. For that is used the reverse bar ``, just delete all the reverse bars from the string in the server and thats all. Clean the string. Commented Aug 12, 2019 at 7:10
  • Yes how could I do from android java params pass not to change from No8ANfBX/0GAWJnF4v0bQwf/4UiJ7qY7rOPfrfB0XMQ= to No8ANfBX\/0GAWJnF4v0bQwf\/4UiJ7qY7rOPfrfB0XMQ= Commented Aug 12, 2019 at 7:14
  • 1
    Is the '\\' really there or are you just seeing it in the debugger? Commented Aug 12, 2019 at 8:33
  • There are a couple things to unpack here and I don't see enough info in the question to do so. First, it appears what you call the password is already encrypted and base64 encoded. I say this because when I base64 decode it I get a nice length (32 bytes) of random-looking bytes. Second, where is this "decrypted password at the server" coming from? Where is that code? Commented Aug 12, 2019 at 12:29

1 Answer 1

1

You need to pass your password with UTF-8 formate & also decrypt from server end with UTF-8 So it would be like URLEncoder.encode("No8ANfBX/0GAWJnF4v0bQwf/4UiJ7qY7rOPfrfB0XMQ=", "utf-8")

Sign up to request clarification or add additional context in comments.

3 Comments

Wouldn't you use Encoding.UTF8 for that? Either use GetBytes on that directly, or if you really want/need to use the URLEncorder you can pass Encoding.UTF8 instead of "utf-8".
This is not an UTF8 related problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.