Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

  1. // hex.h - written and placed in the public domain by Wei Dai
  2. //! \file
  3. //! \brief Classes for HexEncoder and HexDecoder
  4. #ifndef CRYPTOPP_HEX_H
  5. #define CRYPTOPP_HEX_H
  6. #include "cryptlib.h"
  7. #include "basecode.h"
  8. NAMESPACE_BEGIN(CryptoPP)
  9. //! Converts given data to base 16
  10. class CRYPTOPP_DLL HexEncoder : public SimpleProxyFilter
  11. {
  12. public:
  13. HexEncoder(BufferedTransformation *attachment = NULL, bool uppercase = true, int outputGroupSize = 0, const std::string &separator = ":", const std::string &terminator = "")
  14. : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment)
  15. {
  16. IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), outputGroupSize)(Name::Separator(), ConstByteArrayParameter(separator))(Name::Terminator(), ConstByteArrayParameter(terminator)));
  17. }
  18. void IsolatedInitialize(const NameValuePairs &parameters);
  19. };
  20. //! Decode base 16 data back to bytes
  21. class CRYPTOPP_DLL HexDecoder : public BaseN_Decoder
  22. {
  23. public:
  24. HexDecoder(BufferedTransformation *attachment = NULL)
  25. : BaseN_Decoder(GetDefaultDecodingLookupArray(), 4, attachment) {}
  26. void IsolatedInitialize(const NameValuePairs &parameters);
  27. private:
  28. static const int * CRYPTOPP_API GetDefaultDecodingLookupArray();
  29. };
  30. NAMESPACE_END
  31. #endif