- Main Page
- Namespaces
- Classes
- Files

# hex.cpp

    00001 // hex.cpp - written and placed in the public domain by Wei Dai
    00002
    00003 #include "pch.h"
    00004
    00005 #ifndef CRYPTOPP_IMPORTS
    00006
    00007 #include "hex.h"
    00008
    00009 NAMESPACE_BEGIN(CryptoPP)
    00010
    00011 static const byte s_vecUpper[] = "0123456789ABCDEF";
    00012 static const byte s_vecLower[] = "0123456789abcdef";
    00013
    00014 void HexEncoder::IsolatedInitialize(const NameValuePairs &parameters)
    00015 {
    00016         bool uppercase = parameters.GetValueWithDefault(Name::Uppercase(), true);
    00017         m_filter->Initialize(CombinedNameValuePairs(
    00018                 parameters,
    00019                 MakeParameters(Name::EncodingLookupArray(), uppercase ? &s_vecUpper[0] : &s_vecLower[0], false)(Name::Log2Base(), 4, true)));
    00020 }
    00021
    00022 void HexDecoder::IsolatedInitialize(const NameValuePairs &parameters)
    00023 {
    00024         BaseN_Decoder::IsolatedInitialize(CombinedNameValuePairs(
    00025                 parameters,
    00026                 MakeParameters(Name::DecodingLookupArray(), GetDefaultDecodingLookupArray(), false)(Name::Log2Base(), 4, true)));
    00027 }
    00028
    00029 const int *HexDecoder::GetDefaultDecodingLookupArray()
    00030 {
    00031         static bool s_initialized = false;
    00032         static int s_array[256];
    00033
    00034         if (!s_initialized)
    00035         {
    00036                 InitializeDecodingLookupArray(s_array, s_vecUpper, 16, true);
    00037                 s_initialized = true;
    00038         }
    00039         return s_array;
    00040 }
    00041
    00042 NAMESPACE_END
    00043
    00044 #endif