crytoppp库分析-base64
来源:互联网 发布:百胜拆分 知乎 编辑:程序博客网 时间:2024/06/06 02:44
具体如下:
0-25:A-Z
26-51:a-z
52-61:0-9
62:+
63:/
64:=(填充符)
// base64.cpp - written and placed in thepublic domain by Wei Dai
#include "pch.h"
#include "base64.h"
NAMESPACE_BEGIN(CryptoPP)
//定义字母表
static const byte s_vec[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const byte s_padding = '=';
//编码初始化,初始化ProxyFilter代理过滤类的member_ptr<B
//ufferedTransformation>m_filter;缓冲区传送信息
void Base64Encoder::IsolatedInitialize(constNameValuePairs ¶meters)
{
//换行符,行长度
bool insertLineBreaks =parameters.GetValueWithDefault(Name::InsertLineBreaks(),true);
int maxLineLength =parameters.GetIntValueWithDefault(Name::MaxLineLength(),72);
const char *lineBreak =insertLineBreaks ? "/n" : "";
//MakeParameters的参数依次为:字母表、填充符、分隔符、终结符、
//LONGTOBASE以6位二进制为基数
m_filter->Initialize(CombinedNameValuePairs(
parameters,
MakeParameters(Name::EncodingLookupArray(),&s_vec[0], false)
(Name::PaddingByte(),s_padding)
(Name::GroupSize(),insertLineBreaks ? maxLineLength : 0)
(Name::Separator(),ConstByteArrayParameter(lineBreak))
(Name::Terminator(),ConstByteArrayParameter(lineBreak))
(Name::Log2Base(),6, true)));
}
//得到解码数组
const int*Base64Decoder::GetDecodingLookupArray()
{
static bool s_initialized = false;
static int s_array[256];
if(!s_initialized)
{
//如果需要初始化,则初始化解码s_array,
//指明是64位的编码
InitializeDecodingLookupArray(s_array,s_vec, 64, false);
s_initialized = true;
}
return s_array;
}
NAMESPACE_END
#ifndef CRYPTOPP_BASE64_H
#define CRYPTOPP_BASE64_H
#include "basecode.h"
NAMESPACE_BEGIN(CryptoPP)
//! Base64 Encoder Class
//类继承情况
//SimpleProxyFilter->Base64Encoder
//BaseN_Decoder->Base64Decoder
class Base64Encoder : public SimpleProxyFilter
{//编码类继承了SimpleProxyFilter简单代理类
public:
//使用换行符、行长度、缓冲区传输信息变量为参数构造
Base64Encoder(BufferedTransformation *attachment= NULL, bool insertLineBreaks = true, int maxLineLength = 72)
: SimpleProxyFilter(newBaseN_Encoder(new Grouper), attachment)
{
IsolatedInitialize(MakeParameters(Name::InsertLineBreaks(),insertLineBreaks)(Name::MaxLineLength(), maxLineLength));
}
voidIsolatedInitialize(const NameValuePairs ¶meters);
};
//! Base64 Decoder Class
class Base64Decoder : public BaseN_Decoder
{//解码类继承了BaseN_Decoder类
public:
Base64Decoder(BufferedTransformation *attachment= NULL)
:BaseN_Decoder(GetDecodingLookupArray(), 6, attachment){}
voidIsolatedInitialize(const NameValuePairs ¶meters){}
private:
static const int * CRYPTOPP_APIGetDecodingLookupArray();
};
NAMESPACE_END
#endif
- crytoppp库分析-base64
- crytoppp库分析-base
- base64算法逆向分析
- Base64编码原理分析
- Base64编码原理分析
- base64位编码原理与分析
- MINA源码分析---base64编码和解码
- base64位编码原理与分析
- java安全架构____java Base64原理分析
- base64
- BASE64
- Base64
- BASE64
- Base64
- Base64
- base64
- base64
- base64
- 数据库语句练习
- 内核在utu2440上的移植
- Windows 7 无法登陆网银
- Struts2源代码分析(二)类ContainerImpl的实现分析
- TOPO研发管理系统的特点和系统设计思路
- crytoppp库分析-base64
- 环中环
- php学习笔记(13):PHP+MYSQL简单分页
- 将java程序安装成windows服务
- FileMon中的Hash表算法代码
- MTK link 错误:“Error: L6221E: Execution region EXTSRAM overlaps with Execution region DUMMY_END.”
- 孔孟之道
- SQLyuju
- SQL