Skip to content

Instantly share code, notes, and snippets.

@passthehashbrowns
Created October 23, 2020 21:34
Show Gist options
  • Save passthehashbrowns/e860a590681484c0125520c696892a55 to your computer and use it in GitHub Desktop.
Save passthehashbrowns/e860a590681484c0125520c696892a55 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Text;
namespace convertfile
{
public static class Program
{
static void Main(string[] args)
{
byte[] fileBytes = File.ReadAllBytes(args[0]);
string results = @"\x" + BitConverter.ToString(fileBytes);
results.Replace("-", string.Empty);
Console.WriteLine(results.Replace("-", @"\x"));
}
public static string ByteArrayToString(byte[] ba)
{
StringBuilder hex = new StringBuilder(ba.Length * 2);
foreach (byte b in ba)
hex.AppendFormat("{0:x2}", b);
return hex.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment