Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

HMACSHA1 encoding change when build for iOS with IL2CPP Scripting Backend in Unity 5.

Discussion in 'iOS and tvOS' started by akkiDev, Mar 19, 2015.

  1. akkiDev

    akkiDev

    Joined:
    Aug 7, 2013
    Posts:
    70
    I am using HMACSHA1 encoding in my project for making signature, everything works fine if I build for iOS without IL2CPP Scripting Backend but signature is changed when build with IL2CPP.

    This is my code :
    Code (csharp):
    1.  
    2. public static string ComputeHmac(string input, byte[] key)
    3.         {
    4.             HMACSHA1 myhmacsha1 = new HMACSHA1(key);
    5.             byte[] byteArray = Encoding.UTF8.GetBytes(input);
    6.             MemoryStream stream = new MemoryStream(byteArray);
    7.             return Convert.ToBase64String(myhmacsha1.ComputeHash(stream));
    8.         }

    Any suggestions would be appreciated.

    Thanks.
     
    Last edited by a moderator: Mar 20, 2015
  2. bigdaddy

    bigdaddy

    Joined:
    May 24, 2011
    Posts:
    153
    There's a bug in encryption in IL2CPP shipped in 5.0 (and 4.6.2)

    Bug is fixed in 4.6.3 and will be in the 5.0 patch
     
  3. akkiDev

    akkiDev

    Joined:
    Aug 7, 2013
    Posts:
    70
    Thanks for your prompt response. Can you please specify which version of Unity 5 it is being fixed?
    Thanks once again.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,775
    @akkiDev

    The 5.0.0p1 patch release contains all of the encryption-related fixes that we know about now. There might still be a problem that we missed, but I would try this version.