I recently had a need of similar human readable encoding. So I searched the net and found one: http://www.crockford.com/wrmg/base32.html As you may see the author uses different alphabet to the one presented!
Thanks, Ivailo Petrov -----Original Message----- From: Lists [mailto:[EMAIL PROTECTED] Sent: Friday, March 19, 2004 4:41 AM To: [EMAIL PROTECTED] Subject: Base32 Encoder for human entry Sorry, I've never had any luck with CVS to contribute stuff. This is a modified version of the HEX encoder which encodes in base 32 without the characters people most often confuse when written: ILO0. It is suitable for when people need to enter encrypted data by hand. Unlike Base64, it is case insensitive, and is 25% smaller than hex encoding. It is NOT the offical Base32 encoding, as that uses confusible characters. If you are going to use this, please further format the data so that it is in blocks of around 5 characters so that it is easier for people to enter correctly. I hope someone finds this useful. This is for Crypto++ Library 5.1. #ifndef CRYPTOPP_BASE32H_H #define CRYPTOPP_BASE32H_H #include "basecode.h" NAMESPACE_BEGIN(CryptoPP) //! Converts given data to base 32 using human readable case-insensitive characters and numbers minus //! ILO0 which are easily confusible in most fonts. Suitable for human entry of encrypted data. class Base32HumanEncoder : public SimpleProxyFilter { public: Base32HumanEncoder(BufferedTransformation *attachment = NULL, bool uppercase = true, int outputGroupSize = 0, const std::string &separator = ":", const std::string &terminator = "") : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment) { IsolatedInitialize(MakeParameters("Uppercase", uppercase)("GroupSize", outputGroupSize)("Separator", ConstByteArrayParameter(separator))); } void IsolatedInitialize(const NameValuePairs ¶meters); }; //! Decode base 32 human readable data back to bytes class Base32HumanDecoder : public BaseN_Decoder { public: Base32HumanDecoder(BufferedTransformation *attachment = NULL) : BaseN_Decoder(GetDecodingLookupArray(), 5, attachment) {} void IsolatedInitialize(const NameValuePairs ¶meters) {} private: static const int *GetDecodingLookupArray(); }; NAMESPACE_END #endif // base32H.cpp - modified version of hex.cpp written and placed in the public domain by Wei Dai // Modifications by Robert Basler #include "pch.h" #include "base32H.h" NAMESPACE_BEGIN(CryptoPP) static const byte s_vecUpper[] = "ABCDEFGHJKMNPQRSTUVWXYZ123456789"; static const byte s_vecLower[] = "abcdefghjkmnpqrstuvwxyz123456789"; void Base32HumanEncoder::IsolatedInitialize(const NameValuePairs ¶meters) { bool uppercase = parameters.GetValueWithDefault("Uppercase", true); m_filter->Initialize(CombinedNameValuePairs( parameters, MakeParameters("EncodingLookupArray", uppercase ? &s_vecUpper[0] : &s_vecLower[0])("Log2Base", 5))); } const int *Base32HumanDecoder::GetDecodingLookupArray() { static bool s_initialized = false; static int s_array[256]; if (!s_initialized) { InitializeDecodingLookupArray(s_array, s_vecUpper, 32, true); s_initialized = true; } return s_array; } NAMESPACE_END
