Ring Daemon
Loading...
Searching...
No Matches
base64.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3
*
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16
*/
17
18
#include "
base64.h
"
19
#include "
connectivity/sip_utils.h
"
20
21
#include <simdutf.h>
22
23
namespace
jami
{
24
namespace
base64 {
25
26
std::string
27
encode
(std::string_view
str
)
28
{
29
std::string
buffer
(simdutf::base64_length_from_binary(
str
.size()),
'\0'
);
30
simdutf::binary_to_base64((
const
char
*)
str
.data(),
str
.size(),
buffer
.data());
31
return
buffer
;
32
}
33
34
std::vector<unsigned char>
35
decode
(std::string_view
str
)
36
{
37
std::vector<unsigned char>
buffer
(simdutf::maximal_binary_length_from_base64(
str
.data(),
str
.size()));
38
const
simdutf::result r = simdutf::base64_to_binary(
str
.data(),
str
.size(), (
char
*)
buffer
.data());
39
if
(r.error)
40
throw
base64_exception
();
41
buffer
.resize(r.count);
// resize the buffer according to actual number of bytes
42
return
buffer
;
43
}
44
45
}
// namespace base64
46
}
// namespace jami
base64.h
jami::base64::base64_exception
Definition
base64.h:30
jami::base64::encode
std::string encode(std::string_view str)
Definition
base64.cpp:27
jami::base64::decode
std::vector< unsigned char > decode(std::string_view str)
Definition
base64.cpp:35
jami
Definition
account.cpp:56
jami::emitSignal
void emitSignal(Args... args)
Definition
jami_signal.h:64
sip_utils.h
src
base64.cpp
Generated on Fri Apr 3 2026 14:23:09 for Ring Daemon by
1.9.8