public static BigInteger HexToBigInteger(string hex) { if (NumberTheory.Mod(hex.Length, 2) != 0) { hex = "0" + hex; } hex = hex.ToLower(); var bytes = new byte[hex.Length / 2 + 1]; for (var i = 0; i < bytes.Length - 1; i++) { bytes[bytes.Length - 2 - i] = HexToByte[hex.Substring(i * 2, 2)]; } return(new BigInteger(bytes)); }
public static byte[] HexToBytes(string hex) { if (NumberTheory.Mod(hex.Length, 2) != 0) { hex = "0" + hex; } hex = hex.ToLower(); var bytes = new byte[hex.Length / 2]; for (var i = 0; i < hex.Length / 2; i++) { bytes[i] = HexToByte[hex.Substring(i * 2, 2)]; } return(bytes); }