Counter Strike : Global Offensive Source Code
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.

44 lines
1.1 KiB

  1. // hex.cpp - written and placed in the public domain by Wei Dai
  2. #include "pch.h"
  3. #ifndef CRYPTOPP_IMPORTS
  4. #include "hex.h"
  5. NAMESPACE_BEGIN(CryptoPP)
  6. static const byte s_vecUpper[] = "0123456789ABCDEF";
  7. static const byte s_vecLower[] = "0123456789abcdef";
  8. void HexEncoder::IsolatedInitialize(const NameValuePairs &parameters)
  9. {
  10. bool uppercase = parameters.GetValueWithDefault(Name::Uppercase(), true);
  11. m_filter->Initialize(CombinedNameValuePairs(
  12. parameters,
  13. MakeParameters(Name::EncodingLookupArray(), uppercase ? &s_vecUpper[0] : &s_vecLower[0], false)(Name::Log2Base(), 4, true)));
  14. }
  15. void HexDecoder::IsolatedInitialize(const NameValuePairs &parameters)
  16. {
  17. BaseN_Decoder::IsolatedInitialize(CombinedNameValuePairs(
  18. parameters,
  19. MakeParameters(Name::DecodingLookupArray(), GetDefaultDecodingLookupArray(), false)(Name::Log2Base(), 4, true)));
  20. }
  21. const int *HexDecoder::GetDefaultDecodingLookupArray()
  22. {
  23. static volatile bool s_initialized = false;
  24. static int s_array[256];
  25. if (!s_initialized)
  26. {
  27. InitializeDecodingLookupArray(s_array, s_vecUpper, 16, true);
  28. s_initialized = true;
  29. }
  30. return s_array;
  31. }
  32. NAMESPACE_END
  33. #endif