/// <summary> /// Verify if the security code created and the security code introduced by the user are the same /// </summary> /// <param name="confirmationCode">String, security code written by the user</param> /// <returns>Bool, true if both codes are the same, false if not</returns> public static bool VerifyResume(string confirmationCode) { byte[] confirmationHash = Hash_SHA2.CreateResume(confirmationCode); /* La clase binary es muy eficiente a la hora de hacer equals de dos resumenes hash para ver si son * iguales (https://stackoverflow.com/questions/18472867/checking-equality-for-two-byte-arrays/18472958) */ Binary binaryConfirmationHash = new Binary(confirmationHash); return(binaryOriginalHash.Equals(binaryConfirmationHash)); }
/// <summary> /// Initialice the SHA algorithm and resume the security code created /// </summary> /// <param name="confirmationCode">String, security code created</param> public static void InitialiceVariables(string confirmationCode) { hashResume = new SHA256Managed(); byte[] originalHash = Hash_SHA2.CreateResume(confirmationCode); binaryOriginalHash = new Binary(originalHash); }