public void TestHashGuid() { var result0 = Guid.Empty; var result1 = HashUtilities.ComputeHashGuid(new byte[0]); Console.WriteLine("Hashed to: {0}", result1); Assert.AreNotEqual(result0, result1); var result1B = HashUtilities.ComputeHashGuid(new byte[0]); Console.WriteLine("Hashed to: {0}", result1B); Assert.AreEqual(result1, result1B); var result2 = HashUtilities.ComputeHashGuid(Encoding.ASCII.GetBytes("ClearCanvas.Common.Utilities.Tests")); Console.WriteLine("Hashed to: {0}", result2); Assert.AreNotEqual(result0, result2); Assert.AreNotEqual(result1, result2); var result3 = HashUtilities.ComputeHashGuid(Encoding.ASCII.GetBytes("ClearCanvas.Commom.Utilities.Tests")); Console.WriteLine("Hashed to: {0}", result3); Assert.AreNotEqual(result0, result3); Assert.AreNotEqual(result1, result3); Assert.AreNotEqual(result2, result3); }
public ActionResult Index(KorisnickiNalog korisnickiNalog, string returnUrl) { if (korisnickiNalog.LozinkaPlain != null) { korisnickiNalog.Lozinka = HashUtilities.CalculateMd5Hash(korisnickiNalog.LozinkaPlain); } if (!korisnickiNalog.IsValid) { return(View(korisnickiNalog)); } try { var nalog = fRepositoryFactory.KorisnickiNaloziRepository.VratiKorisnickiNalog(korisnickiNalog.KorisnickoIme, korisnickiNalog.LozinkaPlain); var cookie = FormsAuthentication.GetAuthCookie(korisnickiNalog.KorisnickoIme, false); var ticket = new FormsAuthenticationTicket(1, korisnickiNalog.KorisnickoIme, DateTime.Now, DateTime.Now.AddMonths(6), false, nalog.ID.ToString()); cookie.Value = FormsAuthentication.Encrypt(ticket); Response.Cookies.Add(cookie); var korisnik = fRepositoryFactory.KorisnickiNaloziRepository.VratiKorisnikaSaUlogama(nalog.ID); Session.Add("Korisnik", korisnik); if (string.IsNullOrEmpty(returnUrl)) { return(RedirectToAction("Index", "Home")); } return(Redirect(returnUrl)); } catch (LoginException le) { ViewBag.Error = le.Message; return(View(korisnickiNalog)); } }
public static CacheKey GetKey(DbCommand command, DbContext context, CachePolicy cachePolicy) { if (command is null) { throw new ArgumentNullException(nameof(command)); } if (cachePolicy is null) { throw new ArgumentNullException(nameof(cachePolicy)); } byte[] buffer = Encoding.UTF8.GetBytes(command.CommandText); var encodedString = Convert.ToBase64String(buffer); var cacheKey = GetCacheKey(command, cachePolicy.CacheSaltKey); var cacheKeyHash = $"{HashUtilities.ComputeHash(encodedString)}"; var cacheDependencies = GetCacheDependencies(command, context, cachePolicy); return(new CacheKey { Key = cacheKey, KeyHash = cacheKeyHash, CacheDependencies = cacheDependencies }); }
public User(string username, string name, string password, UserType type) { UserName = username; Name = name; Password = HashUtilities.HashPassword(password); UserType = type; }
protected virtual TContext CreateContext( TOptions options, IAnalysisLogger logger, RuntimeConditions runtimeErrors, string filePath = null) { var context = new TContext { Logger = logger, RuntimeErrors = runtimeErrors }; if (filePath != null) { context.TargetUri = new Uri(filePath); if (options.ComputeFileHashes) { if (_pathToHashDataMap != null && _pathToHashDataMap.TryGetValue(filePath, out HashData hashData)) { context.Hashes = hashData; } else { context.Hashes = HashUtilities.ComputeHashes(filePath); } } } return(context); }
/// <summary> /// Compute the SHA-1 hash of the given file, then add it to InstrumentFiles /// </summary> /// <param name="instrumentFile"></param> /// <returns></returns> public bool AddInstrumentFile(FileInfo instrumentFile) { var sha1Hash = HashUtilities.ComputeFileHashSha1(instrumentFile.FullName); AddInstrumentFile(instrumentFile.Name, instrumentFile.Length, sha1Hash, HashUtilities.HashTypeConstants.SHA1); return(true); }
public KorisnickiNalog VratiKorisnickiNalog(string korisnickoIme, string lozinka) { if (korisnickoIme == null) { throw new LoginException("Korisničko ime nije uneto"); } if (lozinka == null) { throw new LoginException("Lozinka nije uneta"); } var korisnik = DataContext.KorisnickiNalozi.SingleOrDefault(x => x.KorisnickoIme == korisnickoIme); if (korisnik == null) { throw new LoginException("Korisničko ime nije pronađeno"); } var hash = HashUtilities.CalculateMd5Hash(lozinka); var okLozinka = korisnik.Lozinka.SequenceEqual(hash); if (!okLozinka) { throw new LoginException("Lozinka se ne poklapa"); } return(korisnik); }
public SarifLogger( TextWriter textWriter, LoggingOptions loggingOptions = DefaultLoggingOptions, OptionallyEmittedData dataToInsert = OptionallyEmittedData.None, OptionallyEmittedData dataToRemove = OptionallyEmittedData.None, Tool tool = null, Run run = null, IEnumerable <string> analysisTargets = null, IEnumerable <string> invocationTokensToRedact = null, IEnumerable <string> invocationPropertiesToLog = null, string defaultFileEncoding = null) : this(textWriter, loggingOptions) { if (dataToInsert.HasFlag(OptionallyEmittedData.Hashes)) { AnalysisTargetToHashDataMap = HashUtilities.MultithreadedComputeTargetFileHashes(analysisTargets); } _run = run ?? CreateRun( analysisTargets, dataToInsert, dataToRemove, invocationTokensToRedact, invocationPropertiesToLog, defaultFileEncoding, AnalysisTargetToHashDataMap); tool = tool ?? Tool.CreateFromAssemblyData(); _run.Tool = tool; _dataToInsert = dataToInsert; _dataToRemove = dataToRemove; _issueLogJsonWriter.Initialize(_run); }
internal void ImportXmlFromString(string xml, out VisualTreeAsset vta) { vta = ScriptableObject.CreateInstance <VisualTreeAsset>(); vta.visualElementAssets = new List <VisualElementAsset>(); vta.templateAssets = new List <TemplateAsset>(); var h = new Hash128(); byte[] b = Encoding.UTF8.GetBytes(xml); HashUtilities.ComputeHash128(b, ref h); vta.contentHash = h.GetHashCode(); XDocument doc; try { doc = XDocument.Parse(xml, LoadOptions.SetLineInfo); } catch (Exception e) { logger.LogError(ImportErrorType.Syntax, ImportErrorCode.InvalidXml, e, Error.Level.Fatal, null); return; } LoadXmlRoot(doc, vta); StyleSheet inlineSheet = ScriptableObject.CreateInstance <StyleSheet>(); inlineSheet.name = "inlineStyle"; m_Builder.BuildTo(inlineSheet); vta.inlineSheet = inlineSheet; }
protected override void ComputeHashCodePartsSpecific(ref RoslynHashCode hashCode) { hashCode.Add(TrackInstanceFields.GetHashCode()); hashCode.Add(DisposeOwnershipTransferAtConstructor.GetHashCode()); hashCode.Add(DisposeOwnershipTransferAtMethodCall.GetHashCode()); hashCode.Add(HashUtilities.Combine(DisposeOwnershipTransferLikelyTypes)); }
/// <summary> /// Compute a hash of the settings. /// </summary> /// <returns>The computed hash.</returns> public Hash128 ComputeHash() { var h = new Hash128(); var h2 = new Hash128(); HashUtilities.ComputeHash128(ref type, ref h); HashUtilities.ComputeHash128(ref mode, ref h2); HashUtilities.AppendHash(ref h2, ref h); HashUtilities.ComputeHash128(ref lighting, ref h2); HashUtilities.AppendHash(ref h2, ref h); HashUtilities.ComputeHash128(ref proxySettings, ref h2); HashUtilities.AppendHash(ref h2, ref h); h2 = cameraSettings.GetHash(); HashUtilities.AppendHash(ref h2, ref h); if (influence != null) { h2 = influence.ComputeHash(); HashUtilities.AppendHash(ref h2, ref h); } if (proxy != null) { h2 = proxy.ComputeHash(); HashUtilities.AppendHash(ref h2, ref h); } return(h); }
protected override void ComputeHashCodePartsSpecific(Action <int> addPart) { addPart(TrackInstanceFields.GetHashCode()); addPart(DisposeOwnershipTransferAtConstructor.GetHashCode()); addPart(DisposeOwnershipTransferAtMethodCall.GetHashCode()); addPart(HashUtilities.Combine(DisposeOwnershipTransferLikelyTypes)); }
private AnalysisEntity( ISymbol?symbol, ImmutableArray <AbstractIndex> indices, SyntaxNode?instanceReferenceOperationSyntax, InterproceduralCaptureId?captureId, PointsToAbstractValue location, ITypeSymbol type, AnalysisEntity?parent, bool isThisOrMeInstance) { Debug.Assert(!indices.IsDefault); Debug.Assert(symbol != null || !indices.IsEmpty || instanceReferenceOperationSyntax != null || captureId.HasValue); Debug.Assert(parent == null || parent.Type.HasValueCopySemantics() || !indices.IsEmpty); Symbol = symbol; Indices = indices; InstanceReferenceOperationSyntax = instanceReferenceOperationSyntax; CaptureId = captureId; InstanceLocation = location; Type = type; Parent = parent; IsThisOrMeInstance = isThisOrMeInstance; _ignoringLocationHashCodeParts = ComputeIgnoringLocationHashCodeParts(); EqualsIgnoringInstanceLocationId = HashUtilities.Combine(_ignoringLocationHashCodeParts); }
public override int GetHashCode() { return(HashUtilities.Combine( this.PropertyName.GetHashCodeOrDefault(), HashUtilities.Combine(this.MapFromValueContentAbstractValue.GetHashCodeOrDefault(), this.MapFromNullAbstractValue.GetHashCodeOrDefault()))); }
protected virtual void AnalyzeTargets( TOptions options, IEnumerable <Skimmer <TContext> > skimmers, TContext rootContext, IEnumerable <string> targets) { var disabledSkimmers = new SortedSet <string>(); foreach (Skimmer <TContext> skimmer in skimmers) { PerLanguageOption <RuleEnabledState> ruleEnabledProperty = DefaultDriverOptions.CreateRuleSpecificOption(skimmer, DefaultDriverOptions.RuleEnabled); RuleEnabledState ruleEnabled = rootContext.Policy.GetProperty(ruleEnabledProperty); FailureLevel failureLevel = (ruleEnabled == RuleEnabledState.Default || ruleEnabled == RuleEnabledState.Disabled) ? default : (FailureLevel)Enum.Parse(typeof(FailureLevel), ruleEnabled.ToString()); if (ruleEnabled == RuleEnabledState.Disabled) { disabledSkimmers.Add(skimmer.Id); Warnings.LogRuleExplicitlyDisabled(rootContext, skimmer.Id); RuntimeErrors |= RuntimeConditions.RuleWasExplicitlyDisabled; } else if (!skimmer.DefaultConfiguration.Enabled && ruleEnabled == RuleEnabledState.Default) { // This skimmer is disabled by default, and the configuration file didn't mention it. // So disable it, but don't complain that the rule was explicitly disabled. disabledSkimmers.Add(skimmer.Id); } else if (skimmer.DefaultConfiguration.Level != failureLevel && ruleEnabled != RuleEnabledState.Default && ruleEnabled != RuleEnabledState.Disabled) { skimmer.DefaultConfiguration.Level = failureLevel; } } if (disabledSkimmers.Count == skimmers.Count()) { Errors.LogAllRulesExplicitlyDisabled(rootContext); ThrowExitApplicationException(rootContext, ExitReason.NoRulesLoaded); } if ((options.DataToInsert.ToFlags() & OptionallyEmittedData.Hashes) != 0) { // If analysis is persisted to a disk log file, we will have already // computed all file hashes and stored them to _pathToHashDataMap. _pathToHashDataMap = _pathToHashDataMap ?? HashUtilities.MultithreadedComputeTargetFileHashes(targets, options.Quiet); } foreach (string target in targets) { using (TContext context = DetermineApplicabilityAndAnalyze(options, skimmers, rootContext, target, disabledSkimmers)) { RuntimeErrors |= context.RuntimeErrors; } } }
static Hash128 ComputeCustomIndexerHash(MethodInfo mi, CustomObjectIndexerAttribute attr) { var id = $"{mi.DeclaringType.FullName}.{mi.Name}.{attr.version}"; Hash128 dataHash = default; HashUtilities.ComputeHash128(System.Text.Encoding.ASCII.GetBytes(id), ref dataHash); return(dataHash); }
public override int GetHashCode() { var hashCode = new RoslynHashCode(); HashUtilities.Combine(this.InterfaceInfos, ref hashCode); HashUtilities.Combine(this.ConcreteInfos, ref hashCode); return(hashCode.ToHashCode()); }
public override int GetHashCode() { return(HashUtilities.Combine( this._hazardousUsageBuilder.GetHashCode(), this._visitedLocalFunctions.GetHashCode(), this._visitedLambdas.GetHashCode(), base.GetHashCode())); }
public static void RunSingleTest(Type testClass, string testMethod) { AssemblyPrep.TestEngine .RunTests( new[] { HashUtilities.GuidForTestCycleID(AssemblyPrep.Source, testClass.FullName + "." + testMethod) }, 0, AssemblyPrep.Logger); }
public override int GetHashCode() { return(HashUtilities.CombineHashCodes( this.CompilerName?.GetHashCode() ?? 0, this.CompilerType.GetHashCode(), this.CompilerPath?.GetHashCode() ?? 0, this.DebuggeeArchitecture.GetHashCode())); }
public override int GetHashCode() { int hash = 0; HashUtilities.AdditiveHash(ref hash, HealthNumber.GetHashCode()); HashUtilities.AdditiveHash(ref hash, MilestoneReached.GetHashCode()); return(hash); }
public override int GetHashCode() { return(HashUtilities.Combine( this.ContainingTypeName.GetHashCodeOrDefault(), HashUtilities.Combine(this.MethodName.GetHashCodeOrDefault(), HashUtilities.Combine(this.ParameterNameOfPropertySetObject.GetHashCodeOrDefault(), this.InvocationEvaluator.GetHashCodeOrDefault())))); }
static void ComputeProbeBakingHashes(int count, Hash128 allProbeDependencyHash, HDProbeBakingState *states) { for (int i = 0; i < count; ++i) { states[i].probeBakingHash = states[i].probeSettingsHash; HashUtilities.ComputeHash128(ref allProbeDependencyHash, ref states[i].probeBakingHash); } }
protected override int ComputeHashCode() { return(HashUtilities.Combine(CreationOpt?.GetHashCode() ?? 0, HashUtilities.Combine(SymbolOpt?.GetHashCode() ?? 0, HashUtilities.Combine(AnalysisEntityOpt?.GetHashCode() ?? 0, HashUtilities.Combine(LocationTypeOpt?.GetHashCode() ?? 0, HashUtilities.Combine(_isSpecialSingleton.GetHashCode(), IsNull.GetHashCode())))))); }
public ClaimInfo[] GetClaimsForUser(string username, string passwordAsCleartext) { var hashedPassword = HashUtilities.GetMd5Hash(passwordAsCleartext).Replace("-", ""); var identity = Identities.FirstOrDefault(i => string.Compare(username, i.Username, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(hashedPassword, i.Password, StringComparison.OrdinalIgnoreCase) == 0); return(identity?.Claims); }
public override int GetHashCode() { var hashCode = new RoslynHashCode(); HashUtilities.Combine(PropertyAbstractValues, ref hashCode); hashCode.Add(MapFromValueContentAbstractValue.GetHashCodeOrDefault()); hashCode.Add(MapFromPointsToAbstractValue.GetHashCodeOrDefault()); return(hashCode.ToHashCode()); }
public override int GetHashCode() { var h = new Hash128(); HashUtilities.AppendHash(ref m_SceneObjectsHash, ref h); HashUtilities.AppendHash(ref m_SkySettingsHash, ref h); HashUtilities.AppendHash(ref m_AmbientProbeHash, ref h); return(h.GetHashCode()); }
public void TestExecutorNumbers() { MockTests.TryGetValue( HashUtilities.GuidForTestCycleID( AssemblyPrep.Source, AssemblyPrep.ReflectionHelper.GetTestCycleNameForMethodScope(typeof(MockTestClass1))), out UTF.ITestCycle methodCycle); Assert.AreEqual(2, methodCycle.TestMethodContexts.Count); }
public void Register(string username, string password) { string hashedPass = HashUtilities.HashPassword(password); byte[] key = HashUtilities.HashKey(password); string encryptedData = CryptographicUtilities.Encrypt(string.Empty, key); RegistryData.CreateUser(username, hashedPass, encryptedData); }
public override int GetHashCode() { return(HashUtilities.Combine(this.SinkProperties, HashUtilities.Combine(this.SinkMethodParameters, HashUtilities.Combine(StringComparer.Ordinal.GetHashCode(this.FullTypeName), HashUtilities.Combine(this.SinkKinds, HashUtilities.Combine(this.IsInterface.GetHashCode(), this.IsAnyStringParameterInConstructorASink.GetHashCode())))))); }
public void HashUtilitiesConstructorTest() { HashUtilities target = new HashUtilities(); Assert.Inconclusive( "TODO: 实现用来验证目标的代码" ); }