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.

42 lines
1.2 KiB

  1. // base64.cpp - written and placed in the public domain by Wei Dai
  2. #include "pch.h"
  3. #include "base64.h"
  4. NAMESPACE_BEGIN(CryptoPP)
  5. static const byte s_vec[] =
  6. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  7. static const byte s_padding = '=';
  8. void Base64Encoder::IsolatedInitialize(const NameValuePairs &parameters)
  9. {
  10. bool insertLineBreaks = parameters.GetValueWithDefault(Name::InsertLineBreaks(), true);
  11. int maxLineLength = parameters.GetIntValueWithDefault(Name::MaxLineLength(), 72);
  12. const char *lineBreak = insertLineBreaks ? "\n" : "";
  13. m_filter->Initialize(CombinedNameValuePairs(
  14. parameters,
  15. MakeParameters(Name::EncodingLookupArray(), &s_vec[0], false)
  16. (Name::PaddingByte(), s_padding)
  17. (Name::GroupSize(), insertLineBreaks ? maxLineLength : 0)
  18. (Name::Separator(), ConstByteArrayParameter(lineBreak))
  19. (Name::Terminator(), ConstByteArrayParameter(lineBreak))
  20. (Name::Log2Base(), 6, true)));
  21. }
  22. const int *Base64Decoder::GetDecodingLookupArray()
  23. {
  24. static volatile bool s_initialized = false;
  25. static int s_array[256];
  26. if (!s_initialized)
  27. {
  28. InitializeDecodingLookupArray(s_array, s_vec, 64, false);
  29. s_initialized = true;
  30. }
  31. return s_array;
  32. }
  33. NAMESPACE_END