public static Work Parse(string data) { if (data.Length != 256) { return(null); } try { if (BitConverter.IsLittleEndian) { var bin = HexEncoding.Decode(data.Substring(0, 160)); if (bin.Length == 80) { return(new Work(bin)); } } //sorry, we do not support big-endian system return(null); } catch { return(null); } }
static bool ParseInput(Message message, out byte[] data) { data = EmptyByte; if (message.Arguments == null || message.Arguments.Count <= 0) { return(false); } var solution = message.Arguments[0]; if (string.IsNullOrWhiteSpace(solution)) { return(false); } if (solution.Length != 256) { return(false); } try { if (BitConverter.IsLittleEndian) { data = HexEncoding.Decode(solution); return(data.Length == 128); } //sorry, we do not support big-endian system return(false); } catch { return(false); } }