FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppcodec/cppcodec/base32_hex.hpp at master · tplgy/cppcodec · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
tplgy
/
cppcodec
Public
Notifications
You must be signed in to change notification settings
Fork
123
Star
696
Code
Issues
16
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppcodec
/
cppcodec
/
base32_hex.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (63 loc) · 3 KB
Breadcrumbs
cppcodec
/
cppcodec
/
base32_hex.hpp
Copy path
File metadata and controls
76 lines (63 loc) · 3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
*
* Copyright (C) 2015, 2016 Topology LP
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#
ifndef
CPPCODEC_BASE32_HEX
#
define
CPPCODEC_BASE32_HEX
#
include
"
detail/codec.hpp
"
#
include
"
detail/base32.hpp
"
namespace
cppcodec
{
namespace
detail
{
//
RFC 4648 also specifies a hex encoding system which uses 0-9, then A-V.
static
constexpr
const
char
base32_hex_alphabet[] = {
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
,
'
7
'
,
'
8
'
,
'
9
'
,
'
A
'
,
'
B
'
,
'
C
'
,
'
D
'
,
'
E
'
,
'
F
'
,
'
G
'
,
'
H
'
,
'
I
'
,
'
J
'
,
'
K
'
,
'
L
'
,
'
M
'
,
'
N
'
,
'
O
'
,
'
P
'
,
'
Q
'
,
'
R
'
,
'
S
'
,
'
T
'
,
'
U
'
,
'
V
'
};
class
base32_hex
{
public:
template
<
typename
Codec>
using
codec_impl = stream_codec<Codec, base32_hex>;
static
CPPCODEC_ALWAYS_INLINE
constexpr
size_t
alphabet_size
() {
static_assert
(
sizeof
(base32_hex_alphabet) ==
32
,
"
base32 alphabet must have 32 values
"
);
return
sizeof
(base32_hex_alphabet);
}
static
CPPCODEC_ALWAYS_INLINE
constexpr
char
symbol
(
alphabet_index_t
idx)
{
return
base32_hex_alphabet[idx];
}
static
CPPCODEC_ALWAYS_INLINE
constexpr
char
normalized_symbol
(
char
c)
{
//
Lower-case letters are accepted, though not generally expected.
return
(c >=
'
a
'
&& c <=
'
v
'
) ? (c -
'
a
'
+
'
A
'
) : c;
}
static
CPPCODEC_ALWAYS_INLINE
constexpr
bool
generates_padding
() {
return
true
; }
static
CPPCODEC_ALWAYS_INLINE
constexpr
bool
requires_padding
() {
return
true
; }
static
CPPCODEC_ALWAYS_INLINE
constexpr
char
padding_symbol
() {
return
'
=
'
; }
static
CPPCODEC_ALWAYS_INLINE
constexpr
bool
is_padding_symbol
(
char
c) {
return
c ==
'
=
'
; }
static
CPPCODEC_ALWAYS_INLINE
constexpr
bool
is_eof_symbol
(
char
c) {
return
c ==
'
\0
'
; }
//
RFC4648 does not specify any whitespace being allowed in base32 encodings.
static
CPPCODEC_ALWAYS_INLINE
constexpr
bool
should_ignore
(
char
) {
return
false
; }
};
}
//
namespace detail
using
base32_hex = detail::codec<detail::base32<detail::base32_hex>>;
}
//
namespace cppcodec
#
endif
//
CPPCODEC_BASE32_HEX
Back
|
FazBrowse Home
|
New Git URL