Home>

Something I do not go out to encode one variable, tell me how to do it.

Public Class LoginPage EXTENDS Activity {
        Public Static Final String Login= "Login";
        Public Static Final String Password= "Password";
    PROTECTED VOID OnCreate (Bundle SavedInstanceState) {
            super.oncreate (SavedInstanceState);
            setContentView (R.Layout.efrgTaw);
        INAL EDITTEXT LOGININ= (EditText) FindViewByid (R.ID.EDITTEXT2);
        Final EditText Password= (EditText) FindViewByid (R.ID.EDITTEXT3);
        Button Button= (Button) FindViewByid (R.ID.Button1);
            Butlogin.SetonClicklistener (new button.onclicklistener () {
                @OVerride
                Public Void OnClick (View V) {
        Toast.maketext (getBaseContext (), "Please Wait, Connecting to Server.", Toast.length_long) .show ();
    try {
        String LoginValue= Urlencoder.Encode (loginin.gettext (). Tostring (), "UTF-8");
        STRING PASSWORDSTR= URLENCODER.ENCODE (password.gettext (). Tostring (), "UTF-8");
        Httpclient client= new defaulthttpclient ();
        String URL= "http: //" + AccountValue + ".megaplan.ru /Bumscommonapiv01 /user /authorize.api /" + LoginValue + Passwordstr + "";
        Log.i ("httpget", url);
    try {
        String setServerString= "";
        Httpget httpget= new httpget (URL);
        ResponseHandler <
String >
 ResponseHandler= New BasicResponseHandler ();
        SetServerString= Client.Execute (httpget, responsehandler);
        } Catch (ClientProtocolexception E) {
        E.PrintStackTrace ();
        } Catch (IoException E) {
        E.PrintStackTrace ();
} finally {}
        } Catch (unsupportedencodingException E) {
        E.PrintStackTrace ();
        } finally {}}});}}

I want to pass the Password in the form of MD5. It is Password, Login not touch.

This option did not want to work:

Messagedigest Digest= java.security.messagedigest.getInstance ("MD5");
Digest.update (password.getbytes ());
Byte Messagedigest []= Digest.digest ();
STRINGBUFFER MD5HASH= new stringbuffer ();
for (int i= 0; i <
 Messagedigest.Length; I ++) {
String H= Integer.TohexString (0xFF &
 Messagedigest [i]);
While (H.Length () <
 2)
H= "0" + H;
MD5Hash.APPEND (H);}

>This option did not want to work, however, it is quite faithful. And in general, explain what it means "did not want to work"?

falstaf2021-06-07 14:31:18

does not encode my password, and is transmitted to the server with a clean view (maybe this piece of code I do not do it there? ((

Imire2021-06-07 14:31:18

In the above code, I do not see the hashing, as received Passwordstr from EditText, so send, in its pure form.

falstaf2021-06-07 14:31:18

Thanks for the prompt))) I did not notice like that)))

Imire2021-06-07 14:31:18