2
From: http://www.adp-gmbh.ch/cpp/common/base64.html
4
base64.cpp and base64.h
6
Copyright (C) 2004-2008 René Nyffenegger
8
This source code is provided 'as-is', without any express or implied
9
warranty. In no event will the author be held liable for any damages
10
arising from the use of this software.
12
Permission is granted to anyone to use this software for any purpose,
13
including commercial applications, and to alter it and redistribute it
14
freely, subject to the following restrictions:
16
1. The origin of this source code must not be misrepresented; you must not
17
claim that you wrote the original source code. If you use this source code
18
in a product, an acknowledgment in the product documentation would be
19
appreciated but is not required.
21
2. Altered source versions must be plainly marked as such, and must not be
22
misrepresented as being the original source code.
24
3. This notice may not be removed or altered from any source distribution.
26
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
28
This file was modified by jmarantz@google.com to:
29
- add a web-safe variant that uses '-' and '_' in lieu of '+' and '/'
30
- change the 'decode' interface to return false if the input contains
31
characters not in the expected char-set.
34
#ifndef THIRD_PARTY_BASE64_BASE64_H_
35
#define THIRD_PARTY_BASE64_BASE64_H_
39
// Initialize the base64 library. Call this before other methods if
40
// multi-threaded access is required.
43
// Encode/deocde strings in common base64 encoding
44
std::string base64_encode(const unsigned char* data, unsigned int len);
45
bool base64_decode(const std::string& s, std::string* output);
47
// Encode/deocde strings in a base64 encoding for URL values.
48
std::string web64_encode(const unsigned char* data, unsigned int len);
49
bool web64_decode(const std::string& s, std::string* output);
51
#endif // THIRD_PARTY_BASE64_BASE64_H_