// just an unoptimized example of SHA1 hashing public static string GetHash(string firstBuildHash) { var stringBytes = StringUtils.StringToBytes(firstBuildHash); var sha1 = new SHA1Wrapper(); var hash = sha1.ComputeHash(stringBytes); sha1.Clear(); return(StringUtils.HashBytesToHexString(hash)); }
private List <BuildHashes> GetHashedBuilds(BuildReport report) { var sha1 = new SHA1Wrapper(); List <BuildHashes> result = null; #if UNITY_ANDROID result = GetAndroidBuildHashes(report, GetFileFilters(), sha1); #elif UNITY_STANDALONE_WIN result = GetStandaloneWindowsBuildHashes(report, GetFileFilters(), sha1); #endif sha1.Clear(); return(result); }
/// <summary> /// Calls selection dialog and calculates hashes for the selected build. /// </summary> /// <returns>Valid BuildHashes instance or null in case of error / user cancellation.</returns> public static BuildHashes CalculateExternalBuildHashes() { var buildPath = EditorUtility.OpenFilePanel("Select Standalone Windows build exe or Android build apk / aab", "", "exe,apk,aab"); if (string.IsNullOrEmpty(buildPath)) { Debug.Log(ACTkConstants.LogPrefix + "Hashing cancelled by user."); return(null); } var extension = Path.GetExtension(buildPath); if (string.IsNullOrEmpty(extension)) { return(null); } extension = extension.ToLower(CultureInfo.InvariantCulture); BuildHashes result = null; var sha1 = new SHA1Wrapper(); try { var il2Cpp = PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) == ScriptingImplementation.IL2CPP; if (extension == ".apk" || extension == ".aab") { result = GetAndroidArchiveHashes(buildPath, CodeHashGenerator.GetFileFiltersAndroid(il2Cpp), sha1); } else { var buildFolder = Path.GetDirectoryName(buildPath); var filters = CodeHashGenerator.GetFileFiltersStandaloneWindows(il2Cpp); result = StandaloneWindowsWorker.GetBuildHashes(buildFolder, filters, sha1); } } catch (Exception e) { Debug.LogError(ACTkConstants.LogPrefix + "Error while trying to hash build: " + e); } finally { sha1.Clear(); EditorUtility.ClearProgressBar(); } return(result); }