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.

39 lines
1.2 KiB

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