CClash.HashUtil.DigestString C# (CSharp) Method

DigestString() public method

public DigestString ( string input ) : DataHash
input string
return DataHash
        public DataHash DigestString(string input)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();

            var rv = new DataHash()
            {
                InputName = "string",
                Result = DataHashResult.Ok,
                Hash = new SoapHexBinary( md5.ComputeHash( System.Text.Encoding.Unicode.GetBytes( input ) ) ).ToString()
            };
            return rv;
        }

Usage Example

        public DataHash DeriveHashKey(ICompiler comp, IEnumerable <string> args)
        {
            Logging.Emit("compiler is {0}", comp.CompilerExe);
            var comphash = DigestCompiler(comp.CompilerExe);

            if (comphash.Result == DataHashResult.Ok)
            {
                var srchash = hasher.DigestBinaryFile(comp.SingleSourceFile);
                if (srchash.Result == DataHashResult.Ok)
                {
                    var buf = new StringBuilder();
                    buf.AppendLine(CacheInfo.CacheFormat);
                    buf.AppendLine(srchash.Hash);
                    buf.AppendLine(comp.WorkingDirectory);
                    string incs = null;
                    comp.EnvironmentVariables.TryGetValue("INCLUDE", out incs);
                    if (incs != null)
                    {
                        buf.AppendLine(incs);
                    }

                    foreach (var a in args)
                    {
                        buf.AppendLine(a);
                    }
                    buf.AppendLine(comphash.Hash);

                    comphash = hasher.DigestString(buf.ToString());
                }
            }
            return(comphash);
        }
All Usage Examples Of CClash.HashUtil::DigestString