text: /*
   * Copyright (c) 2021, Krisna Pranav
   *
   * SPDX-License-Identifier: BSD-2-Clause
   */
  
  #pragma once
  
  #include <base/ByteBuffer.h>
  #include <base/Optional.h>
  #include <base/String.h>
  #include <base/StringView.h>
  
  namespace Base {
  
  constexpr u8 decode_hex_digit(char digit)
  {
      if (digit >= '0' && digit <= '9')
          return digit - '0';
      if (digit >= 'a' && digit <= 'f')
          return 10 + (digit - 'a');
      if (digit >= 'A' && digit <= 'F')
          return 10 + (digit - 'A');
      return 255;
  }
  
  Optional<ByteBuffer> decode_hex(const StringView&);
  
  String encode_hex(ReadonlyBytes);
  
  }
  
  using Base::decode_hex;
  using Base::decode_hex_digit;
  using Base::encode_hex;
  