Search Unity

Sha1 hash is different in the Unity3d editor and on the iPhone6 device

Discussion in 'Scripting' started by VeTaL, Mar 5, 2015.

  1. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125
    I'm running the code

    var signatureBase ="CAAVRwZBSsH38BAJF7Ct1wUF3GRctdE9a0mHpmMZCa9UtlQMZBRaVC9dupKBuqlPp2BL7x12muSo0p9YZCnwajGBR7UJsNhIr9JWtnWJCaqf3k8azY50Ka87umbvd6mQKo19en0t5wCKRyPITCJtm4WP74MYa8XVNPyL1YABTwZB6xWsh37ZA0ISvDvoMVRfGLzkkWulZA8qqZC71b4kRWkBB";
    byte[] signatureBytes =new SHA1Managed().ComputeHash(System.Text.Encoding.UTF8.GetBytes(signatureBase));
    SoapHexBinary shb =newSoapHexBinary( signatureBytes );
    Debug.LogError(shb.ToString());

    and getting different results:

    device: 409E73E8A9971EB82435FE38556D37D2C888E22C
    editor: 0CE1044C1D0CB90036811DD0C3B659A09FE5C2C3


    Funny part is that difference had appeared several days ago. Before that, the hash from the editor was the same as on the device: server is expecting 0CE1044C1D0CB90036811DD0C3B659A09FE5C2C3 in the current case. I can connect via Editor, but Devices are failed to connect.

    Tested devices: 2x iPhone6. Reproducible on both.
     
  2. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125
    It seems to be a IL2CPP issue.

    If to compile without it, i'm getting 0CE1044C1D0CB90036811DD0C3B659A09FE5C2C3.
    But if to compile with IL2CPP enabled and run it on x64 compatible device, i'm getting 409E73E8A9971EB82435FE38556D37D2C888E22C.
     
    Last edited: Mar 5, 2015
  3. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125
    Case solved.

    Unity 4.6.3, Sha1 is generating wrong result.
    On Unity 4.6.2 it works fine on both device and editor.
     
  4. VeTaL

    VeTaL

    Joined:
    Jul 2, 2012
    Posts:
    125