Вопрос

I'm sending username and password from android app to web service using skoap2, web service connects to MySQL database. it works perfect with password as text, but if I send an encrypted password, I got illegalCharacterException when creating SoapEnvelope. I think I got the idea what is the problem, but I have no idea how can I solve it. in what form (now String) should I pass the encrypted password and how to store it in the database? (will varchar cause same error)?

String password = ((TextView)findViewById(R.id.passwordr1)).getText().toString();
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); //$NON-NLS-1$
messageDigest.update(password.getBytes());
String encryptedPassword = new String(messageDigest.digest());

later in the code

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

...

PropertyInfo passwordProp =new PropertyInfo();
passwordProp.setName("password");
passwordProp.setValue(params[1]);
passwordProp.setType(String.class);
request.addProperty(passwordProp);

...

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);       
HttpTransportSE ht = new HttpTransportSE(URL);
ht.call(SOAP_ACTION, envelope);
String response = (SoapPrimitive)envelope.getResponse().toString();
Это было полезно?

Решение

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top