System.Security.Cryptography.MD5.Create()

Here are the examples of the csharp api System.Security.Cryptography.MD5.Create() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1012 Examples 7

19 Source : Helper.cs
with MIT License
from 0ffffffffh

public static string Md5(string v)
        {
            return HashWith(MD5.Create(),v);
        }

19 Source : Ribbon.cs
with GNU General Public License v3.0
from 0dteam

static string CalculateMD5(string filename)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filename))
                {
                    var hash = md5.ComputeHash(stream);
                    return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
                }
            }
        }

19 Source : Program.cs
with MIT License
from 0xDivyanshu

public static string CreateMD5(string input)
        {
            // Use input string to calculate MD5 hash
            using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
            {
                byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
                byte[] hashBytes = md5.ComputeHash(inputBytes);

                // Convert the byte array to hexadecimal string
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < hashBytes.Length; i++)
                {
                    sb.Append(hashBytes[i].ToString("X2"));
                }
                return sb.ToString();
            }
        }

19 Source : DefaultCacheKeyBuilder.cs
with MIT License
from 1100100

private static string HashCacheKey(string source)
        {
            if (string.IsNullOrWhiteSpace(source))
                return string.Empty;

            _md5Hasher ??= MD5.Create();
            var bytes = Encoding.UTF8.GetBytes(source);
            var hash = _md5Hasher.ComputeHash(bytes);
            return ToString(hash);
        }

19 Source : Md5Encrypt.cs
with MIT License
from 17MKH

public string Encrypt(byte[] source, bool lowerCase = false)
    {
        if (source == null)
            return null;

        using var md5Hash = MD5.Create();
        return md5Hash.ComputeHash(source).ToHex(lowerCase);
    }

19 Source : Md5Encrypt.cs
with MIT License
from 17MKH

public string Encrypt(Stream inputStream, bool lowerCase = false)
    {
        if (inputStream == null) return null;

        using var md5Hash = MD5.Create();
        return md5Hash.ComputeHash(inputStream).ToHex(lowerCase);
    }

19 Source : GuidMd5OrSha1.cs
with MIT License
from 3F

internal static Guid NewGuid(string input, AlgoVersion version)
        {
            const int _FMT = 16; // The UUID format is 16 octets

            if(input == null) return Guid.Empty;

            byte[] ret = new byte[_FMT];
            using(HashAlgorithm alg = (version == AlgoVersion.Md5) ? MD5.Create() : (HashAlgorithm)SHA1.Create())
            {
                byte[] ns = NamespaceTest.ToByteArray();

                alg.TransformBlock(ChangeByteOrder(ns), 0, _FMT, null, 0);

                byte[] strBytes = Encoding.UTF8.GetBytes(input);
                alg.TransformFinalBlock(strBytes, 0, strBytes.Length);

                Array.Copy(alg.Hash, 0, ret, 0, _FMT);
            }

            ret[6] &= 0x0F;
            ret[6] |= (byte)((byte)version << 4);

            ret[8] &= 0x3F;
            ret[8] |= 0x80;

            return new Guid(ChangeByteOrder(ret));
        }

19 Source : StringExtension.cs
with MIT License
from 3F

public static Guid Guid(this string str)
        {
            if(System.Guid.TryParse(str, out Guid res)) {
                return res;
            }

            if(str == null) {
                str = String.Empty;
            }

            using(MD5 md5 = MD5.Create()) {
                return new Guid(md5.ComputeHash(Encoding.UTF8.GetBytes(str)));
            }
        }

19 Source : QQTea.cs
with MIT License
from 499116344

public static byte[] MD5(byte[] data)
        {
            var md5Instance = System.Security.Cryptography.MD5.Create();
            return md5Instance.ComputeHash(data);
        }

19 Source : TeaCrypter.cs
with MIT License
from 499116344

public byte[] MD5(byte[] data)
        {
            return System.Security.Cryptography.MD5.Create().ComputeHash(data);
        }

19 Source : QQUser.cs
with MIT License
from 499116344

public byte[] Md52()
        {
            var byteBuffer = new BinaryWriter(new MemoryStream());
            byteBuffer.Write(MD51);
            byteBuffer.BeWrite(0);
            byteBuffer.BeWrite(QQ);
            return MD5.Create().ComputeHash(((MemoryStream) byteBuffer.BaseStream).ToArray());
        }

19 Source : OKCoinAPI.cs
with MIT License
from aabiryukov

private static string GetSignature(NameValueDictionary args, string secretKey)
	    {
		    var sb = new StringBuilder();
			foreach (var arg in args)
			{
				sb.Append(arg.Key);
				sb.Append("=");
				sb.Append(arg.Value);
				sb.Append("&");
			}

			sb.Append("secret_key=");
		    sb.Append(secretKey);

		    using (var md = MD5.Create())
		    {
				using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(sb.ToString())))
		        {
			        var hashData = md.ComputeHash(stream);

					// Format as hexadecimal string.
					var hashBuilder = new StringBuilder();
					foreach (byte data in hashData)
					{
						hashBuilder.Append(data.ToString("x2", CultureInfo.InvariantCulture));
					}
					return hashBuilder.ToString().ToUpperInvariant();
		        }
		    }
	    }

19 Source : UI.cs
with MIT License
from aaaddress1

private void compile_Click(object sender, EventArgs e)
        {

            (new System.Threading.Thread(() =>
            {
                this.Invoke((MethodInvoker)delegate () {
                    compile.Enabled = false;
                    logBox.Clear();
                    logMsg(demostr, Color.Blue);
                    this.splitContainer.Panel2Collapsed = false;
                    this.logPanelBtn.Text = "x";
                });
                File.WriteAllText(srcPath, this.fastColoredTextBox.Text);
                File.Delete(exePath);
                File.Delete(asmPath);
                File.Delete(obfAsmPath);

                logMsg(" --- \n", Color.Blue);
                logMsg(string.Format(
                        "[\tInfo\t] current compile info... \n" +
                        " - source: {0}\n" +
                        " - asm path: {1}\n" +
                        " - obfuscated asm path: {2}\n" +
                        " - output exe path: {3}\n", srcPath, asmPath, obfAsmPath, exePath), Color.Blue);

                if (compiler.geneateAsmSource(srcPath, asmPath))
                    logMsg("[\tOK\t] generate replacedembly code of source code.", Color.Green);
                else
                {
                    logMsg("[\tFail\t] generate replacedembly code of sorce code failure ...", Color.Red);
                    this.Invoke((MethodInvoker)delegate () { compile.Enabled = true; });
                    return;
                }

                if (obfuscator.obfuscaAsm(asmPath, obfAsmPath))
                    logMsg("[\tOK\t] generate obfuscated replacedembly code of source code.", Color.Green);
                else
                {
                    logMsg("[\tFail\t] generate obfuscated replacedembly code of sorce code failure ...", Color.Red);
                    this.Invoke((MethodInvoker)delegate () { compile.Enabled = true; });
                    return;
                }
                if (compiler.generateExe(obfAsmPath, exePath))
                {
                    var arr = System.IO.File.ReadAllBytes(exePath);
                    var size = arr.Length;
                    var md5 = BitConverter.ToString(MD5.Create().ComputeHash(arr)).Replace("-", "");
                    var sha256 = BitConverter.ToString(SHA256.Create().ComputeHash(arr)).Replace("-", "");
                    logMsg("[\tInfo\t] exe size: " + size + " bytes", Color.Blue);
                    logMsg("[\tInfo\t] MD5: " + md5, Color.Blue);
                    logMsg("[\tInfo\t] SHA256: " + sha256, Color.Blue);
                    logMsg("[\tOK\t] generate executable file successfully :)", Color.Green);
                }
                else
                    logMsg("[\tFail\t] generate executable file failure ... o___O", Color.Red);
 
                if (Properties.Settings.Default.clnAftCompile)
                {
                    File.Delete(asmPath);
                    File.Delete(obfAsmPath);
                }
                this.Invoke((MethodInvoker)delegate () { compile.Enabled = true; });
            })
            { IsBackground = true }).Start();
        }

19 Source : HuobiAPI.cs
with MIT License
from aabiryukov

[System.Diagnostics.Codereplacedysis.SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.String.ToLower")]
        private static string GetSignature(IEnumerable<KeyValuePair<string, string>> args)
	    {
	        var input = string.Join("&", args.Select(arg => arg.Key + "=" + arg.Value));
            var asciiBytes = Encoding.ASCII.GetBytes(input);
	        using (var md5 = MD5.Create())
	        {
	            var hashedBytes = md5.ComputeHash(asciiBytes);
	            var hashedString = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
	            return hashedString;
	        }
	    }

19 Source : StreamVideoSourceHandler.cs
with MIT License
from adamfisher

private string GetFileName(Stream stream, string format)
        {
            var hasher = MD5.Create();
            var hashBytes = hasher.ComputeHash(stream);
			stream.Position = 0;
			var hash = Convert.ToBase64String(hashBytes)
				.Replace("=", string.Empty)
				.Replace("\\", string.Empty)
				.Replace("/", string.Empty);
			return $"{hash}_temp.{format}";
        }

19 Source : ValidateCopiedFoldersIntegrity.cs
with MIT License
from adrenak

static string CreateMd5ForFolder(string path)
        {
            // replaceduming you want to include nested folders
            var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)
                                 .OrderBy(p => p).ToList();

            MD5 md5 = MD5.Create();

            for (int i = 0; i < files.Count; i++)
            {
                string file = files[i];

                // hash path
                string relativePath = file.Substring(path.Length + 1);
                byte[] pathBytes = Encoding.UTF8.GetBytes(relativePath.ToLower());
                md5.TransformBlock(pathBytes, 0, pathBytes.Length, pathBytes, 0);

                // hash contents
                byte[] contentBytes = File.ReadAllBytes(file);
                if (i == files.Count - 1)
                    md5.TransformFinalBlock(contentBytes, 0, contentBytes.Length);
                else
                    md5.TransformBlock(contentBytes, 0, contentBytes.Length, contentBytes, 0);
            }

            return BitConverter.ToString(md5.Hash).Replace("-", "").ToLower();
        }

19 Source : Program.cs
with GNU General Public License v3.0
from AdriaandeJongh

static string GetMD5(string filepath)
        {
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filepath))
                {
                    return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", string.Empty).ToLowerInvariant();
                }
            }
        }

19 Source : IdenticonGenerator.cs
with Apache License 2.0
from advanced-cms

private int GetStringHash(string str)
        {
            var md5Hasher = MD5.Create();
            var hashed = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(str));
            var integerValue = BitConverter.ToUInt64(hashed, 0);
            return (int)integerValue;
        }

19 Source : Device.cs
with MIT License
from AeonLucid

public static Device Generate()
        {
            // DeviceId
            var deviceIdBuilder = new StringBuilder();
            var deviceGuid = Guid.NewGuid().ToString().Replace("-", "");

            deviceIdBuilder.Append("a0"); // Static.
            deviceIdBuilder.Append(deviceGuid); // Can be anything [0-9a-z]{32}.

            using (var md5 = MD5.Create())
            {
                var hash = md5.ComputeHash(Encoding.ASCII.GetBytes(deviceGuid));
                var hashStr = Encoding.ASCII.GetBytes(BitConverter.ToString(hash).Replace("-", "").ToLower());

                deviceIdBuilder.Append(hashStr[12]); // Checksum byte 1.
                deviceIdBuilder.Append(hashStr[16]); // Checksum byte 2.
            }

            return new Device
            {
                DeviceId = deviceIdBuilder.ToString()
            };
        }

19 Source : Helpers.cs
with GNU General Public License v3.0
from Aetsu

public static void CalculateMD5Files(string folder)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("     Calculating md5...");
            Console.ResetColor();
            string[] fileList = Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories);
            List<string> md5List = new List<string>();
            foreach (string filename in fileList)
            {
                using (var md5 = MD5.Create())
                {
                    using (var stream = File.OpenRead(filename))
                    {
                        var hash = md5.ComputeHash(stream);
                        md5List.Add(filename + " - " + BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant());
                    }
                }
            }
            File.WriteAllLines(Path.Combine(new string[] { folder, "md5.txt" }), md5List);
        }

19 Source : PlatformLoader.cs
with GNU General Public License v3.0
from affederaffe

private static string ComputeHash(byte[] data)
        {
            using MD5 md5 = MD5.Create();
            byte[] hash = md5.ComputeHash(data);
            return BitConverter.ToString(hash).Replace("-", string.Empty).ToLowerInvariant();
        }

19 Source : LicensePacker.cs
with MIT License
from AhmedMinegames

[STAThread]
        static void Main()
        {
            try
            {
                bool IsPresent = false;
                CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref IsPresent);
                if (Debugger.IsAttached || IsDebuggerPresent() || IsPresent || CloseHandleAntiDebug())
                {
                    Environment.Exit(0);
                }
                else
                {
                    if (!File.Exists(Environment.CurrentDirectory + @"\SOS13"))
                    {
                        MessageBox.Show("Please Make a SOS13 file in the current program directory and enter the program license to it to continue.", "License Not Found", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        IntPtr NtdllModule = GetModuleHandle("ntdll.dll");
                        IntPtr DbgUiRemoteBreakinAddress = GetProcAddress(NtdllModule, "DbgUiRemoteBreakin");
                        IntPtr DbgUiConnectToDbgAddress = GetProcAddress(NtdllModule, "DbgUiConnectToDbg");
                        byte[] Int3InvaildCode = { 0xCC };
                        WriteProcessMemory(Process.GetCurrentProcess().Handle, DbgUiRemoteBreakinAddress, Int3InvaildCode, 6, 0);
                        WriteProcessMemory(Process.GetCurrentProcess().Handle, DbgUiConnectToDbgAddress, Int3InvaildCode, 6, 0);
                        string License = File.ReadAllText(Environment.CurrentDirectory + @"\SOS13");
                        if (string.IsNullOrEmpty(License))
                        {
                            Environment.Exit(0);
                        }
                        else
                        {
                            StringBuilder NewLicense = new StringBuilder();
                            for (int c = 0; c < License.Length; c++)
                                NewLicense.Append((char)((uint)License[c] ^ (uint)Convert.FromBase64String("decryptkeyencryption")[c % 4]));
                            StringBuilder ROT13Encoding = new StringBuilder();
                            Regex regex = new Regex("[A-Za-z]");
                            foreach (char KSXZ in NewLicense.ToString())
                            {
                                if (regex.IsMatch(KSXZ.ToString()))
                                {
                                    int C = ((KSXZ & 223) - 52) % 26 + (KSXZ & 32) + 65;
                                    ROT13Encoding.Append((char)C);
                                }
                            }
                            StringBuilder sb = new StringBuilder(); foreach (char c in ROT13Encoding.ToString().ToCharArray()) { sb.Append(Convert.ToString(c, 2).PadLeft(8, '0')); }
                            var GetTextToHEX = Encoding.Unicode.GetBytes(sb.ToString());
                            var BuildHEX = new StringBuilder();
                            foreach (var FinalHEX in GetTextToHEX)
                            {
                                BuildHEX.Append(FinalHEX.ToString("X2"));
                            }
                            string HashedKey = UTF8Encoding.UTF8.GetString(MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(BuildHEX.ToString())));
                            HMACMD5 HMACMD = new HMACMD5();
                            HMACMD.Key = UTF8Encoding.UTF8.GetBytes("LXSO12");
                            string HashedKey2 = UTF8Encoding.UTF8.GetString(HMACMD.ComputeHash(UTF8Encoding.UTF8.GetBytes(HashedKey)));
                            string DecryptedProgram = TqMIJUcgsXjVgxqJ(ProgramToDecrypt, HashedKey2.ToString(), IV);
                            byte[] ProgramToRun = Convert.FromBase64String(DecryptedProgram);
                            replacedembly RunInMemory = replacedembly.Load(ProgramToRun);
                            RunInMemory.EntryPoint.Invoke(null, null);
                        }
                    }
                }
            }
            catch (CryptographicException)
            {
                MessageBox.Show("Sorry, but looks like your license key are invalid.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }

19 Source : Program.cs
with MIT License
from AhmedMinegames

[STAThread]
        static void Main()
        {
            try
            {
                bool IsPresent = false;
                CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref IsPresent);
                if (Debugger.IsAttached || IsDebuggerPresent() || IsPresent || CloseHandleAntiDebug())
                {
                    Environment.Exit(0);
                }
                else
                {
                    IntPtr NtdllModule = GetModuleHandle("ntdll.dll");
                    IntPtr DbgUiRemoteBreakinAddress = GetProcAddress(NtdllModule, "DbgUiRemoteBreakin");
                    IntPtr DbgUiConnectToDbgAddress = GetProcAddress(NtdllModule, "DbgUiConnectToDbg");
                    byte[] Int3InvaildCode = { 0xCC };
                    WriteProcessMemory(Process.GetCurrentProcess().Handle, DbgUiRemoteBreakinAddress, Int3InvaildCode, 6, 0);
                    WriteProcessMemory(Process.GetCurrentProcess().Handle, DbgUiConnectToDbgAddress, Int3InvaildCode, 6, 0);
                    string HWID = GetHardwareID();
                    StringBuilder DecryptEncryptionKey = new StringBuilder();
                    for (int c = 0; c < HWID.Length; c++)
                        DecryptEncryptionKey.Append((char)((uint)HWID[c] ^ (uint)Convert.FromBase64String("SOS12")[c % 4]));
                    StringBuilder ROT13Encoding = new StringBuilder();
                    Regex regex = new Regex("[A-Za-z]");
                    foreach (char KSXZ in DecryptEncryptionKey.ToString())
                    {
                        if (regex.IsMatch(KSXZ.ToString()))
                        {
                            int C = ((KSXZ & 223) - 52) % 26 + (KSXZ & 32) + 65;
                            ROT13Encoding.Append((char)C);
                        }
                    }
                    string HashedKey = UTF8Encoding.UTF8.GetString(MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(ROT13Encoding.ToString())));
                    var GetTextToHEX = Encoding.Unicode.GetBytes(HashedKey);
                    var BuildHEX = new StringBuilder();
                    foreach (var FinalHEX in GetTextToHEX)
                    {
                        BuildHEX.Append(FinalHEX.ToString("X2"));
                    }
                    StringBuilder sb = new StringBuilder(); foreach (char c in BuildHEX.ToString().ToCharArray()) { sb.Append(Convert.ToString(c, 2).PadLeft(8, '0')); }
                    byte[] keys = MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(sb.ToString()));
                    StringBuilder builder = new StringBuilder();
                    for (int i = 0; i < keys.Length; i++)
                    {
                        builder.Append(keys[i].ToString("x2"));
                    }
                    string DecryptedProgram = TqMIJUcgsXjVgxqJ(ProgramToDecrypt, builder.ToString(), IV);
                    byte[] ProgramToRun = Convert.FromBase64String(DecryptedProgram);
                    replacedembly RunInMemory = replacedembly.Load(ProgramToRun);
                    RunInMemory.EntryPoint.Invoke(null, null);
                }
            }
            catch(CryptographicException)
            {
                MessageBox.Show("Sorry But looks like you are not authorized to use this program.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }

19 Source : Main.cs
with MIT License
from AhmedMinegames

private void HWIDPacking(string FileToPack, string Output)
        {
            var Options = new Dictionary<string, string>();
            Options.Add("CompilerVersion", "v4.0");
            Options.Add("language", "c#");
            var codeProvider = new CSharpCodeProvider(Options);
            CompilerParameters parameters = new CompilerParameters();
            parameters.CompilerOptions = "/target:winexe";
            parameters.GenerateExecutable = true;
            parameters.Outputreplacedembly = Output;
            parameters.IncludeDebugInformation = false;
            string[] Librarys = { "System", "System.Windows.Forms", "System.Management", "System.Core", "System.Runtime", "System.Runtime.InteropServices" };
            foreach (string Library in Librarys)
            {
                parameters.Referencedreplacedemblies.Add(Library + ".dll");
            }
            byte[] CodeToProtect = File.ReadAllBytes(FileToPack);
            string RandomIV = RandomPreplacedword(16);
            string RandomKey = RandomPreplacedword(4);
            StringBuilder ROT13Encoding = new StringBuilder();
            Regex regex = new Regex("[A-Za-z]");
            foreach (char KSXZ in XOREncryptionKeys(textBox2.Text, RandomKey))
            {
                if (regex.IsMatch(KSXZ.ToString()))
                {
                    int C = ((KSXZ & 223) - 52) % 26 + (KSXZ & 32) + 65;
                    ROT13Encoding.Append((char)C);
                }
            }
            AesAlgorithms EncryptingBytes = new AesAlgorithms();
            string EncryptedKey = UTF8Encoding.UTF8.GetString(MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(ROT13Encoding.ToString())));
            var GetTextToHEX = Encoding.Unicode.GetBytes(EncryptedKey);
            var BuildHEX = new StringBuilder();
            foreach (var FinalHEX in GetTextToHEX)
            {
                BuildHEX.Append(FinalHEX.ToString("X2"));
            }
            StringBuilder sb = new StringBuilder(); foreach (char c in BuildHEX.ToString().ToCharArray()) { sb.Append(Convert.ToString(c, 2).PadLeft(8, '0')); }
            byte[] keys = MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(sb.ToString()));
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < keys.Length; i++)
            {
                builder.Append(keys[i].ToString("x2"));
            }
            string Final = EncryptingBytes.AesTextEncryption(Convert.ToBase64String(CodeToProtect), builder.ToString(), RandomIV);
            string HWIDPacker = Resource1.HWIDPacker;
            string NewHWIDPackerCode = HWIDPacker.Replace("DecME", Final).Replace("THISISIV", RandomIV).Replace("HWIDPacker", "namespace " + RandomName(14));
            string MyShinyNewPacker = NewHWIDPackerCode.Replace("SOS12", Convert.ToBase64String(Encoding.UTF8.GetBytes(RandomKey)));
            codeProvider.CompilereplacedemblyFromSource(parameters, MyShinyNewPacker);
        }

19 Source : Main.cs
with MIT License
from AhmedMinegames

private void LicensePacking(string FileToPack, string Output)
        {
            var Options = new Dictionary<string, string>();
            Options.Add("CompilerVersion", "v4.0");
            Options.Add("language", "c#");
            var codeProvider = new CSharpCodeProvider(Options);
            CompilerParameters parameters = new CompilerParameters();
            parameters.CompilerOptions = "/target:winexe";
            parameters.GenerateExecutable = true;
            parameters.Outputreplacedembly = Output;
            parameters.IncludeDebugInformation = false;
            string[] Librarys = { "System", "System.Windows.Forms", "System.Management", "System.Net", "System.Core", "System.Net.Http", "System.Runtime", "System.Runtime.InteropServices" };
            foreach (string Library in Librarys)
            {
                parameters.Referencedreplacedemblies.Add(Library + ".dll");
            }
            byte[] CodeToProtect = File.ReadAllBytes(FileToPack);
            string RandomIV = RandomPreplacedword(16);
            AesAlgorithms EncryptingBytes = new AesAlgorithms();
            string RandomKey = RandomPreplacedword(4);
            Random rnd = new Random();
            int RandomINT = rnd.Next(6, 13);
            string RandomHashingKey = RandomPreplacedword(RandomINT);
            StringBuilder ROT13Encoding = new StringBuilder();
            Regex regex = new Regex("[A-Za-z]");
            foreach (char KSXZ in XOREncryptionKeys(textBox3.Text, RandomKey))
            {
                if (regex.IsMatch(KSXZ.ToString()))
                {
                    int C = ((KSXZ & 223) - 52) % 26 + (KSXZ & 32) + 65;
                    ROT13Encoding.Append((char)C);
                }
            }
            StringBuilder sb = new StringBuilder(); foreach (char c in ROT13Encoding.ToString().ToCharArray()) { sb.Append(Convert.ToString(c, 2).PadLeft(8, '0')); }
            var GetTextToHEX = Encoding.Unicode.GetBytes(sb.ToString());
            var BuildHEX = new StringBuilder();
            foreach (var FinalHEX in GetTextToHEX)
            {
                BuildHEX.Append(FinalHEX.ToString("X2"));
            }
            string HashedKey = UTF8Encoding.UTF8.GetString(MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(BuildHEX.ToString())));
            HMACMD5 HMACMD = new HMACMD5();
            HMACMD.Key = UTF8Encoding.UTF8.GetBytes("LXSO12".Replace(UTF8Encoding.UTF8.GetString(Convert.FromBase64String("TFhTTzEy")), RandomHashingKey));
            string HashedKey2 = UTF8Encoding.UTF8.GetString(HMACMD.ComputeHash(UTF8Encoding.UTF8.GetBytes(HashedKey)));
            string Final = EncryptingBytes.AesTextEncryption(Convert.ToBase64String(CodeToProtect), HashedKey2.ToString(), RandomIV);
            string LicensePacker = Resource1.LicensePacker;
            string NewLicensePackerCode = LicensePacker.Replace("DecME", Final).Replace("THISISIV", RandomIV).Replace("LicensePacker", "namespace " + RandomName(14));
            string MyShinyNewPacker = NewLicensePackerCode.Replace("decryptkeyencryption", Convert.ToBase64String(Encoding.UTF8.GetBytes(RandomKey))).Replace("SOS13", textBox4.Text).Replace(UTF8Encoding.UTF8.GetString(Convert.FromBase64String("TFhTTzEy")), RandomHashingKey);
            codeProvider.CompilereplacedemblyFromSource(parameters, MyShinyNewPacker);
        }

19 Source : EncryptionHelper.cs
with MIT License
from aishang2015

public static string MD5Encrypt(string str)
        {
            using (var md5 = MD5.Create())
            {
                byte[] buffer = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
                var sb = new StringBuilder();
                for (int i = 0; i < buffer.Length; i++)
                {
                    sb.Append(buffer[i].ToString("X2"));
                }
                return sb.ToString();
            }
        }

19 Source : StringOperation.cs
with MIT License
from AiursoftWeb

public static string GetMD5(this string sourceString)
        {
            string hash = GetMd5Hash(MD5.Create(), sourceString);
            return hash;
        }

19 Source : StringOperation.cs
with MIT License
from AiursoftWeb

public static string GetMD5(this byte[] data)
        {
            using MD5 md5 = MD5.Create();
            var hash = md5.ComputeHash(data);
            string hex = BitConverter.ToString(hash);
            return hex.Replace("-", "");
        }

19 Source : AES.cs
with MIT License
from AiursoftWeb

private void DeriveKeyAndIV(string preplacedphrase, byte[] salt, out byte[] key, out byte[] iv)
        {
            var concatenatedHashes = new List<byte>(48);
            var preplacedword = Encoding.UTF8.GetBytes(preplacedphrase);
            var currentHash = new byte[0];
            var md5 = MD5.Create();
            bool enoughBytesForKey = false;
            while (!enoughBytesForKey)
            {
                int preHashLength = currentHash.Length + preplacedword.Length + salt.Length;
                byte[] preHash = new byte[preHashLength];
                Buffer.BlockCopy(currentHash, 0, preHash, 0, currentHash.Length);
                Buffer.BlockCopy(preplacedword, 0, preHash, currentHash.Length, preplacedword.Length);
                Buffer.BlockCopy(salt, 0, preHash, currentHash.Length + preplacedword.Length, salt.Length);
                currentHash = md5.ComputeHash(preHash);
                concatenatedHashes.AddRange(currentHash);
                if (concatenatedHashes.Count >= 48)
                    enoughBytesForKey = true;
            }
            key = new byte[32];
            iv = new byte[16];
            concatenatedHashes.CopyTo(0, key, 0, 32);
            concatenatedHashes.CopyTo(32, iv, 0, 16);
            md5.Clear();
        }

19 Source : TechLogItem.cs
with MIT License
from akpaevj

public static string GetMd5Hash(string str)
        {
            if (string.IsNullOrEmpty(str))
                return "";

            using var cp = MD5.Create();
            var src = Encoding.UTF8.GetBytes(str);
            var res = cp.ComputeHash(src);

            return BitConverter.ToString(res).Replace("-", null);
        }

19 Source : AssetDuplicateTreeModel.cs
with MIT License
from akof1314

private List<FileMd5Info> GetFileMd5Infos(List<string> fileArray)
        {
            var style = replacedetDanshariStyle.Get();
            var fileList = new List<FileMd5Info>();

            for (int i = 0; i < fileArray.Count;)
            {
                string file = fileArray[i];
                if (string.IsNullOrEmpty(file))
                {
                    i++;
                    continue;
                }
                EditorUtility.DisplayProgressBar(style.progressreplacedle, file, i * 1f / fileArray.Count);
                try
                {
                    using (var md5 = MD5.Create())
                    {
                        FileInfo fileInfo = new FileInfo(file);
                        using (var stream = File.OpenRead(fileInfo.FullName))
                        {
                            FileMd5Info info = new FileMd5Info();
                            info.filePath = fileInfo.FullName;
                            info.fileSize = fileInfo.Length;
                            info.fileTime = fileInfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss");
                            info.md5 = BitConverter.ToString(md5.ComputeHash(stream)).ToLower();
                            fileList.Add(info);
                        }
                    }

                    i++;
                }
                catch (Exception e)
                {
                    if (!EditorUtility.DisplayDialog(style.errorreplacedle, file + "\n" + e.Message,
                        style.continueStr, style.cancelStr))
                    {
                        EditorUtility.ClearProgressBar();
                        return null;
                    }
                }
            }
            return fileList;
        }

19 Source : Hash.cs
with GNU General Public License v3.0
from AlanMorel

public static string GetHash(string filename)
    {
        string filepath = $"{Paths.RESOURCES_DIR}/{filename}";

        if (!File.Exists(filepath))
        {
            return "";
        }

        using (MD5 md5 = MD5.Create())
        {
            using (FileStream stream = File.OpenRead(filepath))
            {
                byte[] hash = md5.ComputeHash(stream);
                return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
            }
        }
    }

19 Source : ProfilesController.cs
with GNU General Public License v3.0
from AlanMorel

private static string CreateMD5(string input)
    {
        // Use input string to calculate MD5 hash
        using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
        {
            byte[] inputBytes = Encoding.ASCII.GetBytes(input);
            byte[] hashBytes = md5.ComputeHash(inputBytes);

            // Convert the byte array to hexadecimal string
            StringBuilder sb = new();
            for (int i = 0; i < hashBytes.Length; i++)
            {
                sb.Append(hashBytes[i].ToString("X2"));
            }
            return sb.ToString();
        }
    }

19 Source : Criptografia.cs
with MIT License
from alexandrebeato

public static string CriptografarComMD5(string valor)
        {
            using (var md5Hash = MD5.Create())
            {
                string hash = ObterHashMd5(md5Hash, valor);
                return hash;
            }
        }

19 Source : Manager.cs
with Apache License 2.0
from Algoryx

public static bool HasBeenChanged( FileInfo v1, FileInfo v2 )
    {
      if ( v1 == null || !v1.Exists || v2 == null || !v2.Exists )
        return false;

      Func<FileInfo, byte[]> generateMd5 = fi =>
      {
        using ( var stream = fi.OpenRead() ) {
          return System.Security.Cryptography.MD5.Create().ComputeHash( stream );
        }
      };

      return !generateMd5( v1 ).SequenceEqual( generateMd5( v2 ) );
    }

19 Source : HttpRequestMessageBuilder.cs
with MIT License
from aliyun

private Byte[] CalculateContentMd5()
        {
            using (var hasher = MD5.Create())
            {
                return hasher.ComputeHash(this.SerializedContent);
            }
        }

19 Source : CryptoUtil.cs
with MIT License
from aliyunmq

public byte[] ComputeMD5Hash(byte[] data)
            {
                byte[] hashed = MD5.Create().ComputeHash(data);
                return hashed;
            }

19 Source : CryptoUtil.cs
with MIT License
from aliyunmq

public byte[] ComputeMD5Hash(Stream steam)
            {
                byte[] hashed = MD5.Create().ComputeHash(steam);
                return hashed;
            }

19 Source : ColorEncoding.cs
with Apache License 2.0
from allenai

public static Color EncodeTagAsColor(string tag) {
        using (MD5 md5 = MD5.Create()) {

            byte[] data = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(tag));

            return new Color32(data[0], data[1], data[2], data[3]);
        }

    }

19 Source : ImageSynthesis.cs
with Apache License 2.0
from allenai

void Start() {
        // XXXXXXXXXXX************
        // Remember, adding any new Shaders requires them to be included in Project Settings->Graphics->Always Included Shaders
        // otherwise the standlone will build without the shaders and you will be sad


        // default fallbacks, if shaders are unspecified
        if (!uberReplacementShader) {
            uberReplacementShader = Shader.Find("Hidden/UberReplacement");
        }

        if (!opticalFlowShader) {
            opticalFlowShader = Shader.Find("Hidden/OpticalFlow");
        }

#if UNITY_EDITOR

        if (!depthShader) {
            depthShader = Shader.Find("Hidden/DepthBW");
        }
#else
            if (!depthShader)
                depthShader = Shader.Find("Hidden/Depth");

#endif

        // if (!positionShader)
        //	positionShader = Shader.Find("Hidden/World");

        opticalFlowSensitivity = 50.0f;

        // use real camera to capture final image
        capturePreplacedes[0].camera = GetComponent<Camera>();
        for (int q = 1; q < capturePreplacedes.Length; q++) {
            capturePreplacedes[q].camera = CreateHiddenCamera(capturePreplacedes[q].name);
        }
        md5 = System.Security.Cryptography.MD5.Create();

        OnCameraChange();
        OnSceneChange();

    }

19 Source : StringExtensions.cs
with MIT License
from alonsoalon

public static string Md5(this string text)
        {
            String md5 = "";
            MD5 md5_text = MD5.Create();
            byte[] temp = md5_text.ComputeHash(System.Text.Encoding.ASCII.GetBytes(text)); //计算MD5 Hash 值

            for (int i = 0; i < temp.Length; i++)
            {
                md5 += temp[i].ToString("x2"); //转码 每两位转一次16进制
            }
            return md5;
        }

19 Source : MD5Encrypt.cs
with MIT License
from alonsoalon

public static string Encrypt16(string preplacedword)
        {
            if (preplacedword.IsNull())
                return null;

            using (var md5 = MD5.Create())
            {
                return md5.ComputeHash(Encoding.UTF8.GetBytes(preplacedword)).ToHex();
            }
        }

19 Source : MD5Encrypt.cs
with MIT License
from alonsoalon

public static string Encrypt32(string preplacedword = "")
        {
            if (preplacedword.IsNull())
                return null;

            using (var md5 = MD5.Create())
            {
                string pwd = string.Empty;
                byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(preplacedword));
                foreach (var item in s)
                {
                    pwd = string.Concat(pwd, item.ToString("X"));
                }
                return pwd;
            }
        }

19 Source : MD5Encrypt.cs
with MIT License
from alonsoalon

public static string Encrypt64(string preplacedword)
        {
            if (preplacedword.IsNull())
                return null;

            using (var md5 = MD5.Create())
            {
                byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(preplacedword));
                return s.ToBase64();
            }
        }

19 Source : HashHelper.cs
with MIT License
from AlphaYu

public static byte[] GetHashedBytes(HashType type, byte[] bytes, byte[] key)
        {
            if (null == bytes)
            {
                return bytes;
            }

            HashAlgorithm algorithm = null;
            try
            {
                if (key == null)
                {
                    switch (type)
                    {
                        case HashType.MD5:
                            algorithm = MD5.Create();
                            break;

                        case HashType.SHA1:
                            algorithm = SHA1.Create();
                            break;

                        case HashType.SHA256:
                            algorithm = SHA256.Create();
                            break;

                        case HashType.SHA384:
                            algorithm = SHA384.Create();
                            break;

                        case HashType.SHA512:
                            algorithm = SHA512.Create();
                            break;

                        default:
                            algorithm = MD5.Create();
                            break;
                    }
                }
                else
                {
                    switch (type)
                    {
                        case HashType.MD5:
                            algorithm = new HMACMD5(key);
                            break;

                        case HashType.SHA1:
                            algorithm = new HMACSHA1(key);
                            break;

                        case HashType.SHA256:
                            algorithm = new HMACSHA256(key);
                            break;

                        case HashType.SHA384:
                            algorithm = new HMACSHA384(key);
                            break;

                        case HashType.SHA512:
                            algorithm = new HMACSHA512(key);
                            break;

                        default:
                            algorithm = new HMACMD5(key);
                            break;
                    }
                }
                return algorithm.ComputeHash(bytes);
            }
            finally
            {
                algorithm?.Dispose();
            }
        }

19 Source : HelperMethods.cs
with GNU General Public License v3.0
from AM2R-Community-Developers

public static string CalculateMD5(string filename)
        {
            // Check if File exists first
            if (!File.Exists(filename))
                return "";

            using (var stream = File.OpenRead(filename))
            {
                using (var md5 = MD5.Create())
                {
                    var hash = md5.ComputeHash(stream);
                    return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
                }
            }
        }

19 Source : ModPacker.cs
with GNU General Public License v3.0
from AM2R-Community-Developers

private string CalculateMD5(string filename)
        {
            using (var stream = File.OpenRead(filename))
            {
                using (var md5 = MD5.Create())
                {
                    var hash = md5.ComputeHash(stream);
                    return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
                }
            }
        }

19 Source : SongDownloader.cs
with MIT License
from andruzzzhka

public static bool CreateMD5FromFile(string path, out string hash)
        {
            hash = "";
            if (!File.Exists(path)) return false;
            using (MD5 md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(path))
                {
                    byte[] hashBytes = md5.ComputeHash(stream);

                    StringBuilder sb = new StringBuilder();
                    foreach (byte hashByte in hashBytes)
                    {
                        sb.Append(hashByte.ToString("X2"));
                    }

                    hash = sb.ToString();
                    return true;
                }
            }
        }

19 Source : AvatarsHashCache.cs
with MIT License
from andruzzzhka

private static Task<string> CalculateHash(string path)
        {
            return Task.Run(() => {
                return BitConverter.ToString(MD5.Create().ComputeHash(File.ReadAllBytes(path))).Replace("-", "");
            });
        }

19 Source : AuthenticationResponse.cs
with MIT License
from andruzzzhka

private static string hash (string value)
    {
      var src = Encoding.UTF8.GetBytes (value);
      var md5 = MD5.Create ();
      var hashed = md5.ComputeHash (src);

      var res = new StringBuilder (64);
      foreach (var b in hashed)
        res.Append (b.ToString ("x2"));

      return res.ToString ();
    }

See More Examples