예제 #1
0
        public IActionResult PostFromHex([FromBody] HexItem value)
        {
            if (value == null || !ModelState.IsValid)
            {
                return(BadRequest("empty request"));
            }
            HexString hs;

            try {
                hs = new HexString(value.hex);
            } catch (InvalidOperationException e) {
                return(BadRequest("invalid hex string"));
            }

            if (!hs.isValid())
            {
                return(BadRequest("invalid hex string"));
            }
            return(Ok(hs.asBase64()));
        }
예제 #2
0
        public void TestIsValid(String hex)
        {
            HexString hs = new HexString(hex);

            Assert.True(hs.isValid());
        }