repl.it
@johnstev111/

int64-hex

C#

A program that converts a number into it's raw bytes in Little-Endian form.

fork
loading
Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System;

namespace Int64Hex {
  class Int64Hex {
    public static void Main(string[] args) {
      Console.WriteLine("Please insert signed 64-bit integer to get raw bytes.");
      try {
        foreach (byte hm in BitConverter.GetBytes(long.Parse(Console.ReadLine()))) {
          Console.Write($"{hm.ToString("X")}");
        }
        Console.WriteLine();
      } catch (Exception e) {
        Console.WriteLine($"\n{e.GetType().Name}: {e.Message}");
        Environment.Exit(1);
      }
    }
  }
}
// Test [ -7866897547630675894 ] first 
// Output should be [ 4AF8146D5C2AD392 ]