Android Question sha1(md5(string))

Discussion in 'Android Questions' started by Douglas Farias, Oct 2, 2014.

  1. Douglas Farias

    Douglas Farias Expert Licensed 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
     
  2. sorex

    sorex Expert Licensed 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
     
  3. Douglas Farias

    Douglas Farias Expert Licensed User

    can u show me a sample to send?
    i need to send sha1(md5(lala)) for example.
     
  4. sorex

    sorex Expert Licensed User

    I don't know if B4A supports both of them, you'll need to search for it.
     
  5. Douglas Farias

    Douglas Farias Expert Licensed User

    Done i made it. if help someone its here xD
    Code:
    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)
     
    joseluis likes this.
  6. sorex

    sorex Expert Licensed User

    you see that the search is powerfull enough to find what you need (in most case)
     
  7. Douglas Farias

    Douglas Farias Expert Licensed User

    opss
    Code:
    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 *-*
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice