base32.cpp

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

Generated on Sat Dec 23 02:07:05 2006 for Crypto++ by  doxygen 1.5.1-p1