资源简介
使用Base64编解码图片的小例子,希望可以对您的学习有帮助。
代码片段和文件信息
/*
Copyright (c) 2005-2009 by Jakob Schroeter
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied modified sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#include “stdafx.h“
#include “base64.h“
namespace gloox
{
namespace base64
{
static const std::string alphabet64( “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“ );
static const char pad = ‘=‘;
static const char np = (char)std::string::npos;
static char table64vals[] =
{
62 np np np 63 52 53 54 55 56 57 58 59 60 61 np np np np np
np np 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 np np np np np np 26 27 28 29 30 31
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
};
inline char table64( unsigned char c )
{
return ( c < 43 || c > 122 ) ? np : table64vals[c-43];
}
const std::string encode64( const std::string& input )
{
std::string encoded;
char c;
const std::string::size_type length = input.length();
encoded.reserve( length * 2 );
for( std::string::size_type i = 0; i < length; ++i )
{
c = static_cast( ( input[i] >> 2 ) & 0x3f );
encoded += alphabet64[c];
c = static_cast( ( input[i] << 4 ) & 0x3f );
if( ++i < length )
c = static_cast( c | static_cast( ( input[i] >> 4 ) & 0x0f ) );
encoded += alphabet64[c];
if( i < length )
{
c = static_cast( ( input[i] << 2 ) & 0x3c );
if( ++i < length )
c = static_cast( c | static_cast( ( input[i] >> 6 ) & 0x03 ) );
encoded += alphabet64[c];
}
else
{
++i;
encoded += pad;
}
if( i < length )
{
c = static_cast( input[i] & 0x3f );
encoded += alphabet64[c];
}
else
{
encoded += pad;
}
}
return encoded;
}
const std::string decode64( const std::string& input )
{
char c d;
const std::string::size_type length = input.length();
std::string decoded;
decoded.reserve( length );
for( std::string::size_type i = 0; i < length; ++i )
{
c = table64(input[i]);
++i;
d = table64(input[i]);
c = static_cast( ( c << 2 ) | ( ( d >> 4 ) & 0x3 ) );
decoded += c;
if( ++i < length )
{
c = input[i];
if( pad == c )
break;
c = table64(input[i]);
d = static_cast( ( ( d << 4 ) & 0xf0 ) | ( (
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3335 2014-03-27 12:10 ba
文件 1194 2014-03-26 11:27 ba
文件 1753 2014-03-27 13:28 ba
文件 4699 2014-03-27 13:27 ba
文件 1413 2014-03-28 07:32 ba
文件 1417 2014-03-27 13:29 ba
文件 1441 2009-10-13 00:24 ba
文件 1330 2014-03-27 12:09 ba
文件 12040 2014-03-25 08:52 ba
文件 12040 2014-03-27 13:28 ba
文件 298 2014-03-27 12:09 ba
文件 516 2014-03-27 12:09 ba
文件 898 2014-03-27 12:09 ba
目录 0 2014-03-28 07:32 ba
目录 0 2014-03-28 07:33 ba
----------- --------- ---------- ----- ----
42374 15
相关资源
- AutoEncoder用于推荐系统pytorch实现
- JSVM解码器阅读笔记
- CS294A Lecture notes Sparse autoencoder 稀疏自
- Helix AAC Decoder源码及官方文档
- H.264解码器verilog源代码
- js实现页面展示图片
- VHDLDesignandFPGAImplementationofLDPCDecode 一篇
- 11-A0HN
- protobuf-decoder-master.zip
- 易语言encode加密解密源码
-
PotPla
yer播放器离线解码插件 OpenCo - qrencode 静态库编译环境
- BT种子文件解析工具
- OpenCodecSetup64.zip
- 解码器OpenCodecSetup64位
- 解码器OpenCodecSetup64位.exe
- ISL79987 4通道decoders
- HelixMP3Decoder及中文移植手册
- ffmpeg_hw_decode_demo.c
-
ba
se64_hmac_sha1加密算法.rar -
手机端h5裁剪头像ba
se64上传 cropper -
sun.misc.ba
se64Encoder -
ba
se64encoder jar包 -
将ba
se64格式串转换为Image - Interop.WMEncoderLib.dll
-
ba
se64编码解码、无乱码。本人亲自 -
Qt以ba
se64加密作为基础实现3种加解 - 旋转编码开关(Rotary_Encoder_switch)-使
- 飞机大战codecode源码资源 以及svn文件
-
ba
se64源码C实现
评论
共有 条评论