hash - Blackberry MD5 authentication with HTTP Post -


I have to send one server to an email (string) and a password (byte [MD5 hash].

How do I get my MD5 hash below, where "password" is a string (what users enter):

  byte [] passMD5 = Crypto.encodeStringMD5 (password); < / Code> 

and function:

  public static byte [] indicative string throws the exception of the MD5 (strings) {byte [] bytes = s.getBytes (); MD5Digest Digest = New MD5Digest ( Digest.update (Bytes, 0, Bytes Length); Int Length = Digest.GetDigest Lang (); Byte [] MD5 = New Byte [Length]; Digest.getDigest (MD5, 0, True); Return MD 5;}  

Then the "passMD5" should be an MD5 hash in my string value "password" bytes, okay?

Need to send information to a URL and read the results (XML) below to see the rest of the code:

  readURL (urlTemplate, email, passMD5);  

Where urlTemplate is available The string is such that "Email" a string and password to MD5 hash byte.

readURL:

  below the private zero readURL (string URL, string email, byte [] pass) throws IOException {HttpConnection conn = null; InputStream Inn = Null; OutputStream OS = Faucet; Byte databite []; {Try URLEncodedPostData Data = New URL Coded PostData (URL Linked PostData.Default_CHJST, Incorrect); Data.append ("email", email); Data.append ("pass", pass.toString ()); DataBytes = Data. GetBytes (); Conn = (HttpConnection) Connector.open (URL, connector.RAD_virate); Conn.setRequestMethod (HttpConnection.POST); Conn.setRequestProperty ("content-type", data.gate content type ()); Conn.setRequestProperty ("content-length", integer.stosting (databoat.length)); OS = conn.openOutputStream (); Os.write (dataBytes); Os.flush (); Os.close (); In = conn.openInstreamStream (); VerifyLogin (getLoginContent (in)); } Catch (IOE EXPRESS E) {} CATCH (Illegal Bills Exception E) {} Finally {ConnectionUtil.close (Con, In); ConnectionUtil.close (Conn., OS); }}  

Then the password to convert the MD hash to the string can be added to the data. Append () function which only takes the string parameter ... I think its The reason, I do not send good MD5 hash and it creates a problem.

On the server side in ASP.NET C #, I have this:

  byte [] password hash; If (f == 0) {MD5 MD5Hasher = MD5.Create (); PasswordHash = MD5Hasher.ComputeHash (encoding.unycode.getbaytes (password)); } Other {password hash = encoding} Unodod.getbits (password); }  

So when I ask this URL and give it as a password (no such string, byte [] and no MD5 hash) and

  data. Append ("pass", password);  

Then it works.

I have a problem with either my MD5 hash or HTTP POST or both ... Please help me!


Comments