Android Question sha1(md5(string))

Douglas Farias

Expert
Licensed User
Longtime User
hi all, i need send to my php server this information via post
sha1(md5(stringcomasenha)) it is a password of the users
how i made this on b4a?

md5 i see on the forum but md5 + sha1 ???? o_O
 

sorex

Expert
Licensed User
Longtime User
sha1 is also common, especially in data connection encryptions.

worst case you send as MD5 and do the extra SHA1 on the php side
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
can u show me a sample to send?
i need to send sha1(md5(lala)) for example.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I don't know if B4A supports both of them, you'll need to search for it.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
Done i made it. if help someone its here xD
B4X:
    Private pi As String
    pi = "laleqwe"
    Dim md As MessageDigest
    Dim ByteCon As ByteConverter
    Dim passwordhash() As Byte
    Dim passwordhash2() As Byte
    passwordhash = md.GetMessageDigest(pi.GetBytes("UTF8"),"MD5")
    Dim md5string As String
    md5string = ByteCon.HexFromBytes(passwordhash)
    Log(md5string)
    passwordhash2 = md.GetMessageDigest(md5string.GetBytes("UTF8"),"SHA-1")
    Dim SHA1string As String
    SHA1string = ByteCon.HexFromBytes(passwordhash2)
    Log(SHA1string)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
you see that the search is powerfull enough to find what you need (in most case)
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
opss
B4X:
    Private pi As String
    pi = "laleqwe"
    Dim md As MessageDigest
    Dim ByteCon As ByteConverter
    Dim passwordhash() As Byte
    Dim passwordhash2() As Byte
    passwordhash = md.GetMessageDigest(pi.GetBytes("UTF8"),"MD5")
    Dim md5string As String
    md5string = ByteCon.HexFromBytes(passwordhash)
    md5string = md5string.ToLowerCase
    Log(md5string)
    passwordhash2 = md.GetMessageDigest(md5string.GetBytes("UTF8"),"SHA-1")
    Dim SHA1string As String
    SHA1string = ByteCon.HexFromBytes(passwordhash2)
    SHA1string = SHA1string.ToLowerCase
    Log(SHA1string)

here is the code correct need convert to lower case *-*
 
Upvote 1
Top