System.BitConverter.ToString(byte[])

Here are the examples of the csharp api System.BitConverter.ToString(byte[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1296 Examples 7

19 View Source File : Ribbon.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ICachingKeyGenerator.Default.cs
License : MIT License
Project Creator : 1100100

private string MD5(byte[] bytes)
        {
            using (MD5 md5 = new MD5CryptoServiceProvider())
            {
                var hash = md5.ComputeHash(bytes);
                md5.Clear();
                return BitConverter.ToString(hash).Replace("-", "").ToLower();
            }
        }

19 View Source File : VBAGenerator.cs
License : MIT License
Project Creator : 1y0n

public string GenerateScript(byte[] serialized_object, string entry_clreplaced_name, string additional_script, RuntimeVersion version, bool enable_debug)
        {
            string hex_encoded = BitConverter.ToString(serialized_object).Replace("-", "");
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < hex_encoded.Length; i++)
            {
                if (i == 0)
                {
                    builder.Append("s = \"");
                }
                else if (i % 300 == 0)
                {
                    builder.Append("\"");
                    builder.AppendLine();
                    builder.Append("    s = s & \"");
                }
                builder.Append(hex_encoded[i]);
            }
            builder.Append("\"");

            return GetScriptHeader(enable_debug) +
                Global_Var.vba_template.Replace(
                                                "%SERIALIZED%",
                                                builder.ToString()
                                            ).Replace(
                                                "%CLreplaced%",
                                                entry_clreplaced_name
                                            ).Replace(
                                                "%MANIFEST%",
                                                GetManifest(version)
                                            ).Replace(
                                                "%ADDEDSCRIPT%",
                                                additional_script
                                            );
        }

19 View Source File : Form1.cs
License : MIT License
Project Creator : 1y0n

private byte[] Random_Key()
        {
            string t = "";
            for (int i = 0; i < 23; i++)
            {
                RNGCryptoServiceProvider csp = new RNGCryptoServiceProvider();
                byte[] byteCsp = new byte[23];
                csp.GetBytes(byteCsp);
                t = BitConverter.ToString(byteCsp);
            }
            string[] t_array = t.Split('-');
            List<byte> key_list = new List<byte>();

            foreach (string i in t_array)
            {
                key_list.Add(string_to_int(i));
            }

            return key_list.ToArray();
        }

19 View Source File : MD4.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 3gstudent

public static string ComputeHashString(byte[] input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input", "Unable to calculate hash over null input data");
            }
            return BitConverter.ToString(ComputeHash(input)).Replace("-", "");
        }

19 View Source File : MD5Encode.cs
License : Apache License 2.0
Project Creator : 91270

public static string MD5Encrypt(string pwd)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            return BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(pwd))).Replace("-", "").ToUpper();
        }

19 View Source File : PasswordUtil.cs
License : Apache License 2.0
Project Creator : 91270

private static string CreateMD5(string pwd)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(pwd)));
            t2 = t2.Replace("-", "");
            t2 = t2.ToUpper();
            return t2;
        }

19 View Source File : DecorationMaster.cs
License : GNU General Public License v3.0
Project Creator : a2659802

public override string GetVersion()
        {
            replacedembly asm = replacedembly.GetExecutingreplacedembly();

            string ver = Version.ToString("0.000");

            using SHA1 sha1 = SHA1.Create();
            using FileStream stream = File.OpenRead(asm.Location);

            byte[] hashBytes = sha1.ComputeHash(stream);

            string hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();

            return $"{ver}-{hash.Substring(0, 6)}";
        }

19 View Source File : UI.cs
License : MIT License
Project Creator : aaaddress1

private void runPEToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                byte[] file = System.IO.File.ReadAllBytes(this.openFileDialog.FileName);
                string injectSrc = Properties.Resources.templateInjectSrc;

                injectSrc = injectSrc.Replace("{EXECUTABLE_FILE_PAYLOAD}", "{0x" + BitConverter.ToString(file).Replace("-", ", 0x") + "}");
                injectSrc = injectSrc.Replace("{EXECUTABLE_FILE_PATH}", this.openFileDialog.FileName);
                fastColoredTextBox.Clear();
                fastColoredTextBox.InsertText(injectSrc);
            }
            
        }

19 View Source File : UI.cs
License : MIT License
Project Creator : 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 View Source File : WexApi.cs
License : MIT License
Project Creator : aabiryukov

static string ByteArrayToString(byte[] ba)
        {
            return BitConverter.ToString(ba).Replace("-", "");
        }

19 View Source File : HuobiAPI.cs
License : MIT License
Project Creator : 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 View Source File : Loger.cs
License : Apache License 2.0
Project Creator : AantCoder

public static string Bytes(byte[] bs)
        {
            return BitConverter.ToString(bs).Replace('-', ' ');
        }

19 View Source File : SHA2.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static string Hash(SHA2Type type, string data)
        {
            byte[] buffer = Encoding.UTF8.GetBytes(data);

            try
            {
                byte[] digest;
                switch (type)
                {
                    case SHA2Type.SHA256:
                        digest = SHA256.Create().ComputeHash(buffer);
                        break;
                    case SHA2Type.SHA512:
                        digest = SHA512.Create().ComputeHash(buffer);
                        break;
                    default:
                        return "";
                }

                return BitConverter.ToString(digest).Replace("-", "").ToLower();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                return "";
            }
        }

19 View Source File : SecureExtensions.cs
License : MIT License
Project Creator : Accelerider

public static string ToMd5(this string text)
        {
            return BitConverter.ToString(Md5Algorithm.ComputeHash(Encoding.UTF8.GetBytes(text))).Replace("-", string.Empty).ToLower();
        }

19 View Source File : SecureExtensions.cs
License : MIT License
Project Creator : Accelerider

public static string EncryptByRijndael(this string text, byte[] key = null, byte[] iv = null)
        {
            byte[] encryptedInfo;
            using (var rijndaelAlgorithm = new RijndaelManaged())
            {
                rijndaelAlgorithm.Key = key ?? DefaultKey;
                rijndaelAlgorithm.IV = iv ?? DefaultIv;
                var encryptor = rijndaelAlgorithm.CreateEncryptor(rijndaelAlgorithm.Key, rijndaelAlgorithm.IV);

                using (var msEncrypt = new MemoryStream())
                using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                {
                    using (var swEncrypt = new StreamWriter(csEncrypt))
                    {
                        swEncrypt.Write(text);
                    }
                    encryptedInfo = msEncrypt.ToArray();
                }
            }
            return BitConverter.ToString(encryptedInfo).Replace("-", string.Empty);
        }

19 View Source File : SessionConnectionData.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public override string ToString()
        {
            return $"Seeds: [Client {BitConverter.ToString(ClientSeed).Replace("-","")}, Server {BitConverter.ToString(ServerSeed).Replace("-", "")}]";
        }

19 View Source File : PrimitiveExtensions.cs
License : MIT License
Project Creator : actions

public static String ConvertToHex(String base64String)
        {
            var bytes = FromBase64StringNoPadding(base64String);
            return BitConverter.ToString(bytes).Replace("-", String.Empty);
        }

19 View Source File : Message.cs
License : MIT License
Project Creator : adrenak

public override string ToString() {
            StringBuilder sb = new StringBuilder("Message:\n");
            sb.Append("sender=").Append(sender).Append("\n");
            var recipientsJoined = string.Join(", ", recipients);
            sb.Append("recipients={").Append(recipientsJoined).Append("}\n");
            sb.Append("bytesLen=").Append(bytes.Length).Append("\n");
            sb.Append("bytes=").Append(BitConverter.ToString(bytes));
            return sb.ToString();
        }

19 View Source File : Packet.cs
License : MIT License
Project Creator : adrenak

public override string ToString() {
            try {
                StringBuilder sb = new StringBuilder("Packet:");
                sb.Append("\nTag=").Append(Tag);
                sb.Append("\nPayloadLength=").Append(Payload.Length);
                sb.Append("\nPayload=").Append(BitConverter.ToString(Payload));
                return sb.ToString();
            }
            catch { return base.ToString(); }
        }

19 View Source File : ValidateCopiedFoldersIntegrity.cs
License : MIT License
Project Creator : 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 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : CompilationServices.cs
License : MIT License
Project Creator : adrianoc

private static string InternalCompile(string targetPath, string source, bool exe, params string[] references)
        {
            var targetFolder = Path.GetDirectoryName(targetPath);
            if (!Directory.Exists(targetFolder))
            {
                Directory.CreateDirectory(targetFolder);
            }

            var hash = BitConverter.ToString(SHA1.Create().ComputeHash(Encoding.ASCII.GetBytes(source))).Replace("-", "");
            var outputFilePath = $"{targetPath}-{hash}.{(exe ? "exe" : "dll")}";
            if (File.Exists(outputFilePath))
            {
                return outputFilePath;
            }

            var syntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From(source), new CSharpParseOptions());

            var compilationOptions = new CSharpCompilationOptions(
                exe ? OutputKind.ConsoleApplication : OutputKind.DynamicallyLinkedLibrary,
                optimizationLevel: OptimizationLevel.Release,
                allowUnsafe: true);

            var compilation = CSharpCompilation.Create(
                Path.GetFileNameWithoutExtension(outputFilePath),
                new[] {syntaxTree},
                references.Select(r => MetadataReference.CreateFromFile(r)).ToArray(),
                compilationOptions);

            var diagnostics = compilation.GetDiagnostics();
            if (diagnostics.Any(d => d.Severity == DiagnosticSeverity.Error))
            {
                throw new Exception(diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error).Aggregate("", (acc, curr) => acc + "\r\n" + curr.ToString()) + "\r\n\r\n" + source);
            }

            using (var outputreplacedembly = File.Create(outputFilePath))
            {
                compilation.Emit(outputreplacedembly);
            }

            return outputFilePath;
        }

19 View Source File : Form_SteamID64_Editor.cs
License : MIT License
Project Creator : Aemony

private void ReadSteamID()
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata";
            dlg.Filter = "Data files (*.dat)|*.dat";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                filePath = dlg.FileName;

                if (filePath.Contains("SlotData"))
                {
                    // SlotData files stores the SteamID64 in offset 04-11, GameData and SystemData files stores the SteamID64 in offset 00-07
                    fileOffset = 4;
                }
                else
                {
                    fileOffset = 0;
                }
                
                try {
                    using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                    {
                        stream.Position = fileOffset;
                        stream.Read(byteSteamID64, 0, 8);
                    }


                    // Convert to proper IDs.
                    // SteamID64 is stored as Little-Endian in the files, but as Intel is little-endian as well no reversal is needed
                    steamID3 = BitConverter.ToUInt32(byteSteamID64, 0);
                    textBoxSteamID3.Text = steamID3.ToString();

                    steamID64 = BitConverter.ToUInt64(byteSteamID64, 0);
                    textBoxSteamID64.Text = steamID64.ToString();
#if DEBUG
                    Console.WriteLine("Read: " + BitConverter.ToString(byteSteamID64));
                    Console.WriteLine("SteamID3: " + steamID3.ToString());
                    Console.WriteLine("SteamID64: " + steamID64.ToString());
#endif

                    // Misc
                    textBoxWorkingFile.Text = filePath;
                    textBoxWorkingFile.SelectionStart = textBoxWorkingFile.TextLength;
                    toolStripStatusLabel1.Text = "Read from " + Path.GetFileName(filePath) + ": " + BitConverter.ToString(byteSteamID64);
                    lastStatus = toolStripStatusLabel1.Text;

                    // Check if a new ID is already written, and if so, enable the button
                    if (String.IsNullOrWhiteSpace(textBoxSteamID64_New.Text) == false && String.IsNullOrWhiteSpace(filePath) == false && textBoxSteamID64_New.Text != textBoxSteamID64.Text)
                    {
                        buttonUpdate.Enabled = true;
                    }
                    else
                    {
                        buttonUpdate.Enabled = false;
                    }
                } catch (Exception ex)
                {
                    throw ex;
                }
            }

        }

19 View Source File : Form_SteamID64_Editor.cs
License : MIT License
Project Creator : Aemony

private void WriteSteamID()
        {
            steamID64 = Convert.ToUInt64(textBoxSteamID64_New.Text);
            byteSteamID64 = BitConverter.GetBytes(steamID64);
            steamID3 = BitConverter.ToUInt32(byteSteamID64, 0); // Relies on byteSteamID64 having been updated. 

#if DEBUG
            Console.WriteLine("New bytes: " + BitConverter.ToString(byteSteamID64));
            Console.WriteLine("New SteamID3: " + steamID3.ToString());
            Console.WriteLine("New SteamID64: " + steamID64.ToString());
#endif

            // SteamID64 is stored as Little-Endian in the files, but as Intel is little-endian as well no reversal is needed

            try
            {
                // Create a backup first
                File.Copy(filePath, filePath + DateTime.Now.ToString("_yyyy-MM-dd_HH-mm-ss.bak"));

                // Now overwrite the data
                using (Stream stream = File.Open(filePath, FileMode.Open, FileAccess.Write))
                {
                    stream.Position = fileOffset;
                    stream.Write(byteSteamID64, 0, 8);
                }

                textBoxSteamID3.Text = steamID3.ToString();
                textBoxSteamID64.Text = steamID64.ToString();
                toolStripStatusLabel1.Text = "Wrote to " + Path.GetFileName(filePath) + ": " + BitConverter.ToString(byteSteamID64);
                lastStatus = toolStripStatusLabel1.Text;
                buttonUpdate.Enabled = false;

            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

19 View Source File : FileCacheHandler.cs
License : MIT License
Project Creator : AeonLucid

private static string Hash(string input)
        {
            using (var hash = new SHA1CryptoServiceProvider())
            {
                var bytes = hash.ComputeHash(Encoding.ASCII.GetBytes(input));

                return BitConverter.ToString(bytes).Replace("-", string.Empty);
            }
        }

19 View Source File : EmbedAssembly.cs
License : Apache License 2.0
Project Creator : aequabit

public static void Load(string embeddedResource, string fileName)
    {
        if (dic == null)
            dic = new Dictionary<string, replacedembly>();

        byte[] ba = null;
        replacedembly asm = null;
        replacedembly curAsm = replacedembly.GetExecutingreplacedembly();

        using (Stream stm = curAsm.GetManifestResourceStream(embeddedResource))
        {
            // Either the file is not existed or it is not mark as embedded resource
            if (stm == null)
                throw new Exception(embeddedResource + " is not found in Embedded Resources.");

            // Get byte[] from the file from embedded resource
            ba = new byte[(int)stm.Length];
            stm.Read(ba, 0, (int)stm.Length);
            try
            {
                asm = replacedembly.Load(ba);

                // Add the replacedembly/dll into dictionary
                dic.Add(asm.FullName, asm);
                return;
            }
            catch
            {
                // Purposely do nothing
                // Unmanaged dll or replacedembly cannot be loaded directly from byte[]
                // Let the process fall through for next part
            }
        }

        bool fileOk = false;
        string tempFile = "";

        using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider())
        {
            // Get the hash value from embedded DLL/replacedembly
            string fileHash = BitConverter.ToString(sha1.ComputeHash(ba)).Replace("-", string.Empty);

            // Define the temporary storage location of the DLL/replacedembly
            tempFile = Path.GetTempPath() + fileName;

            // Determines whether the DLL/replacedembly is existed or not
            if (File.Exists(tempFile))
            {
                // Get the hash value of the existed file
                byte[] bb = File.ReadAllBytes(tempFile);
                string fileHash2 = BitConverter.ToString(sha1.ComputeHash(bb)).Replace("-", string.Empty);

                // Compare the existed DLL/replacedembly with the Embedded DLL/replacedembly
                if (fileHash == fileHash2)
                {
                    // Same file
                    fileOk = true;
                }
                else
                {
                    // Not same
                    fileOk = false;
                }
            }
            else
            {
                // The DLL/replacedembly is not existed yet
                fileOk = false;
            }
        }

        // Create the file on disk
        if (!fileOk)
        {
            System.IO.File.WriteAllBytes(tempFile, ba);
        }

        // Load it into memory
        asm = replacedembly.LoadFile(tempFile);

        // Add the loaded DLL/replacedembly into dictionary
        dic.Add(asm.FullName, asm);
    }

19 View Source File : Device.cs
License : MIT License
Project Creator : 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 View Source File : SignatureHandlerLocal.cs
License : MIT License
Project Creator : AeonLucid

public Task<SignatureData> GetSignature(string requestInfo, string deviceId)
        {
            var key = $"{SecondaryKey}&{deviceId}";

            using (var hmac = new HMACSHA1(Encoding.ASCII.GetBytes(key)))
            {
                var hashBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(requestInfo));
                var hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLower();

                return Task.FromResult(new SignatureData
                {
                    Sign = $"01a6{hash}"
                });
            }
        }

19 View Source File : Helpers.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : PlatformLoader.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : AsertSigning.cs
License : GNU General Public License v3.0
Project Creator : Agasper

public static string GetHash()
    {
        var a = System.Reflection.replacedembly.GetExecutingreplacedembly();
        return BitConverter.ToString(a.GetName().GetPublicKeyToken()).Replace("-", string.Empty);
    }

19 View Source File : WSRouter.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

protected override void OnNewClient(byte[] idenreplacedy)
            {
                var name = BitConverter.ToString(idenreplacedy);
                Console.WriteLine($"{name} is join");
            }

19 View Source File : WSRouter.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

protected override void OnClientRemoved(byte[] idenreplacedy)
            {
                var name = BitConverter.ToString(idenreplacedy);
                Console.WriteLine($"{name} is left");
            }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev

private void TimerVerif_Tick(object sender, EventArgs e)
        {
            if (proc != null && mem != null && isRunning(false))
            {
                if (btnStartGame.Enabled) ToggleButton(false);
                proc.Refresh();

                try
                {
                    if (proc.PagedMemorySize64 > 0x2000000)
                    {
                        byte step = 0;

                        try
                        {
                            mem.FindFoVOffset(ref pFoV, ref step);

                            if (!isOffsetWrong(pFoV)) progStart();
                            else if (proc.PagedMemorySize64 > (dword_ptr)gameMode.GetValue("c_memSearchRange"))
                            {
                                TimerVerif.Stop();
                                TimerCheck.Stop();

                                //bool offsetFound = false;

                                //int ptrSize = IntPtr.Size * 4;
                                /*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16)
                                {
                                    if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i))
                                    {
                                        pFoV += i;
                                        offsetFound = true;
                                    }

                                    if (i % 50000 == 0)
                                    {
                                        label1.Text = i.ToString();
                                        Update();
                                    }
                                }*/

                                //Console.Beep(5000, 100);

                                //MessageBox.Show("find " + pFoV.ToString("X8"));
                                if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step))
                                {
                                    string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV)));

                                    MessageBox.Show(this, "The memory research pattern wasn't able to find the FoV offset in your " + gameMode.GetValue("c_supportMessage") + ".\n" +
                                                          "Please look for an updated version of this FoV Changer tool.\n\n" +
                                                          "If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n" +
                                                          "\n" + c_toolVer +
                                                          "\nWorking Set: 0x" + proc.WorkingSet64.ToString("X8") +
                                                          "\nPaged Memory: 0x" + proc.PagedMemorySize64.ToString("X8") +
                                                          "\nVirtual Memory: 0x" + proc.VirtualMemorySize64.ToString("X8") +
                                                          "\nStep: " + step.ToString() +
                                                          "\nFoV pointer: 0x" + (pFoV - c_pOffset).ToString("X8") + " = " + memory,
                                                          "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                    pFoV = (dword_ptr)gameMode.GetValue("c_pFoV");
                                    Application.Exit();
                                }
                                else
                                {
                                    //Console.Beep(5000, 100);
                                    SaveSettings();
                                    proc = null;
                                    TimerCheck.Start();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrMessage(ex);
                            Application.Exit();
                        }
                    }
                }
                catch (InvalidOperationException) { }
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev

private void TimerVerif_Tick(object sender, EventArgs e)
        {
            if (proc != null && mem != null && isRunning(false))
            {
                if (btnStartGame.Enabled) ToggleButton(false);
                proc.Refresh();

                if (proc.PagedMemorySize64 > 0x2000000)
                {
                    byte step = 0;

                    try
                    {
                        mem.FindFoVOffset(ref pFoV, ref step);

                        if (!isOffsetWrong(pFoV)) progStart();
                        else if (proc.PagedMemorySize64 > memSearchRange)
                        {
                            TimerVerif.Stop();
                            TimerCheck.Stop();

                            //bool offsetFound = false;

                            //int ptrSize = IntPtr.Size * 4;
                            /*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16)
                            {
                                if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i))
                                {
                                    pFoV += i;
                                    offsetFound = true;
                                }

                                if (i % 50000 == 0)
                                {
                                    label1.Text = i.ToString();
                                    Update();
                                }
                            }*/

                            //Console.Beep(5000, 100);

                            //MessageBox.Show("find " + pFoV.ToString("X8"));
                            if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step))
                            {
                                string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV)));

                                MessageBox.Show("The memory research pattern wasn't able to find the FoV offset in your " + c_supportMessage + ".\n" +
                                                "Please look for an updated version of this FoV Changer tool.\n\n" +
                                                "If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n\n" + c_toolVer +
                                                "\n0x" + Convert.ToInt32(proc.WorkingSet64).ToString("X8") +
                                                "\n0x" + Convert.ToInt32(proc.PagedMemorySize64).ToString("X8") +
                                                "\n0x" + Convert.ToInt32(proc.VirtualMemorySize64).ToString("X8") +
                                                "\nStep = " + step.ToString() +
                                                "\n0x" + (pFoV - 0xC).ToString("X8") + " = " + memory,
                                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                pFoV = c_pFoV;
                                Application.Exit();
                            }
                            else
                            {
                                //Console.Beep(5000, 100);
                                SaveData();
                                proc = null;
                                TimerCheck.Start();
                            }
                        }
                    }
                    catch (Exception err)
                    {
                        ErrMessage(err);
                        Application.Exit();
                    }
                }
            }
        }

19 View Source File : MainForm.cs
License : GNU General Public License v3.0
Project Creator : AgentRev

private void TimerVerif_Tick(object sender, EventArgs e)
        {
            if (proc != null && mem != null && isRunning(false))
            {
                if (btnStartGame.Enabled) ToggleButton(false);
                proc.Refresh();

                if (proc.PagedMemorySize64 > 0x2000000)
                {
                    byte step = 0;

                    try
                    {
                        mem.FindFoVOffset(ref pFoV, ref step);

                        if (!isOffsetWrong(pFoV)) progStart();
                        else if (proc.PagedMemorySize64 > (long)gameMode.GetValue("c_memSearchRange"))
                        {
                            TimerVerif.Stop();
                            TimerCheck.Stop();

                            //bool offsetFound = false;

                            //int ptrSize = IntPtr.Size * 4;
                            /*for (int i = -0x50000; i < 0x50000 && !offsetFound; i += 16)
                            {
                                if (mem.ReadFloat(true, pFoV + i) == 65f && !isOffsetWrong(pFoV + i))
                                {
                                    pFoV += i;
                                    offsetFound = true;
                                }

                                if (i % 50000 == 0)
                                {
                                    label1.Text = i.ToString();
                                    Update();
                                }
                            }*/

                            //Console.Beep(5000, 100);

                            //MessageBox.Show("find " + pFoV.ToString("X8"));
                            if (isRunning(false) && !mem.FindFoVOffset(ref pFoV, ref step))
                            {
                                string memory = BitConverter.ToString(BitConverter.GetBytes(mem.ReadFloat(pFoV)));

                                MessageBox.Show(this, "The memory research pattern wasn't able to find the FoV offset in your " + gameMode.GetValue("c_supportMessage") + ".\n" +
                                                      "Please look for an updated version of this FoV Changer tool.\n\n" +
                                                      "If you believe this might be a bug, please send me an email at [email protected], and include a screenshot of this:\n\n" + c_toolVer +
                                                      "\n0x" + Convert.ToInt32(proc.WorkingSet64).ToString("X8") +
                                                      "\n0x" + Convert.ToInt32(proc.PagedMemorySize64).ToString("X8") +
                                                      "\n0x" + Convert.ToInt32(proc.VirtualMemorySize64).ToString("X8") +
                                                      "\nStep = " + step.ToString() +
                                                      "\n0x" + (pFoV - 0xC).ToString("X8") + " = " + memory,
                                                      "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                                pFoV = (int)gameMode.GetValue("c_pFoV");
                                Application.Exit();
                            }
                            else
                            {
                                //Console.Beep(5000, 100);
                                SaveSettings();
                                proc = null;
                                TimerCheck.Start();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrMessage(ex);
                        Application.Exit();
                    }
                }
            }
        }

19 View Source File : KeyUtil.cs
License : GNU General Public License v3.0
Project Creator : ahmed605

public byte[] FindKey(string gamePath)
        {
            var gameExe = Path.Combine(gamePath, ExecutableName);

            const string validHash = "DEA375EF1E6EF2223A1221C2C575C47BF17EFA5E";
            byte[] key = null;

            var fs = new FileStream(gameExe, FileMode.Open, FileAccess.Read);

            foreach (var u in SearchOffsets)
            {
                if (u <= fs.Length - 32)
                {
                    var tempKey = new byte[32];
                    fs.Seek(u, SeekOrigin.Begin);
                    fs.Read(tempKey, 0, 32);

                    var hash = BitConverter.ToString(SHA1.Create().ComputeHash(tempKey)).Replace("-", "");
                    if (hash == validHash)
                    {
                        key = tempKey;
                        break;
                    }
                }
            }

            fs.Close();

            return key;
        }

19 View Source File : ApiKeyAuthenticationService.cs
License : MIT License
Project Creator : ai-traders

private string ComputeSHA256Hash(string input)
        {
            var bytes = _sha256.ComputeHash(Encoding.ASCII.GetBytes(input));

            return BitConverter
                .ToString(bytes)
                .Replace("-", string.Empty)
                .ToLowerInvariant();
        }

19 View Source File : Encryption.cs
License : GNU General Public License v3.0
Project Creator : aiportal

private static string MD5(string str, Encoding encoding)
		{
			using (System.Security.Cryptography.MD5CryptoServiceProvider provider = new System.Security.Cryptography.MD5CryptoServiceProvider())
			{
				byte[] bs = encoding.GetBytes(str);
				bs = provider.ComputeHash(bs);
				return BitConverter.ToString(bs).Replace("-", "");
			}
		}

19 View Source File : Utils.cs
License : Apache License 2.0
Project Creator : ajuna-network

public static string Bytes2HexString(byte[] bytes, HexStringFormat format = HexStringFormat.Prefixed)
        {
            switch (format)
            {
                case HexStringFormat.Pure:
                    return BitConverter.ToString(bytes).Replace("-", string.Empty);
                case HexStringFormat.Dash:
                    return BitConverter.ToString(bytes);
                case HexStringFormat.Prefixed:
                    return $"0x{BitConverter.ToString(bytes).Replace("-", string.Empty)}";
                default:
                    throw new Exception($"Unimplemented hex string format '{format}'");
            }
        }

19 View Source File : MemoryModule.cs
License : MIT License
Project Creator : Akaion

public IEnumerable<IntPtr> PatternScan(IntPtr baseAddress, byte[] pattern)
        {
            // Ensure the arguments preplaceded in are valid

            if (pattern is null || pattern.Length == 0)
            {
                throw new ArgumentException("One or more of the arguments provided were invalid");
            }
            
            // Convert the pattern into a hexadecimal string
            
            var hexPattern = BitConverter.ToString(pattern).Replace("-", " ").Split().ToList();

            return _patternScanner.FindPattern(baseAddress, hexPattern);
        }

19 View Source File : AssetDuplicateTreeModel.cs
License : MIT License
Project Creator : 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 View Source File : Methods.cs
License : MIT License
Project Creator : AlenToma

public static string Encode(string preplacedword)
        {
            var hash = System.Security.Cryptography.SHA1.Create();
            var encoder = new System.Text.ASCIIEncoding();
            var combined = encoder.GetBytes(preplacedword ?? "");
            return BitConverter.ToString(hash.ComputeHash(combined)).ToLower().Replace("-", "");
        }

19 View Source File : IOUtils.cs
License : MIT License
Project Creator : alexismorin

public static string CreateChecksum( string buffer )
		{
			SHA1 sha1 = SHA1.Create();
			byte[] buf = System.Text.Encoding.UTF8.GetBytes( buffer );
			byte[] hash = sha1.ComputeHash( buf, 0, buf.Length );
			string hashstr = BitConverter.ToString( hash ).Replace( "-", "" );
			return hashstr;
		}

19 View Source File : Signer.cs
License : Apache License 2.0
Project Creator : AlexWan

public string SingData(string signatureString)
        {
            hmac.Initialize();

            byte[] buffer = Encoding.UTF8.GetBytes(signatureString);

            return BitConverter.ToString(hmac.ComputeHash(buffer)).Replace("-", "").ToLower();
        }

19 View Source File : GateIoServer.cs
License : Apache License 2.0
Project Creator : AlexWan

public static string SingRestData(string secretKey, string signatureString)
        {
            var enc = Encoding.UTF8;
            HMACSHA512 hmac = new HMACSHA512(enc.GetBytes(secretKey));
            hmac.Initialize();

            byte[] buffer = enc.GetBytes(signatureString);

            return BitConverter.ToString(hmac.ComputeHash(buffer)).Replace("-", "").ToLower();

        }

19 View Source File : RequestAuthenticator.cs
License : Apache License 2.0
Project Creator : AlexWan

private static string ByteArrayToString(byte[] hash)
        {
            return BitConverter.ToString(hash).Replace("-", "").ToLower();
        }

19 View Source File : FtxRestApi.cs
License : Apache License 2.0
Project Creator : AlexWan

private string GenerateSignature(HttpMethod method, string url, string requestBody)
        {
            _nonce = GetNonce();
            var signature = $"{_nonce}{method.ToString().ToUpper()}{url}{requestBody}";
            var hash = _hashMaker.ComputeHash(Encoding.UTF8.GetBytes(signature));
            var hashStringBase64 = BitConverter.ToString(hash).Replace("-", string.Empty);
            return hashStringBase64.ToLower();
        }

19 View Source File : FtxWebSockerRequestGenerator.cs
License : Apache License 2.0
Project Creator : AlexWan

private static string GenerateSignature(Client client, long time)
        {
            var _hashMaker = new HMACSHA256(Encoding.UTF8.GetBytes(client.ApiSecret));
            var signature = $"{time}websocket_login";
            var hash = _hashMaker.ComputeHash(Encoding.UTF8.GetBytes(signature));
            var hashStringBase64 = BitConverter.ToString(hash).Replace("-", string.Empty);
            return hashStringBase64.ToLower();
        }

See More Examples