- Azonnali navigációs kérdések órája
- Google Pixel topik
- Samsung Galaxy S25 FE - fenséges, felejthető vagy felesleges?
- Magyarországon is kapható a Moto G85 5G
- LG G8X - kettőn áll a vásár
- Huawei Watch GT 3 Pro - korlátolt szépség
- iPhone topik
- MIUI / HyperOS topik
- Huawei Watch GT 6 és GT 6 Pro duplateszt
- Honor Magic6 Pro - kör közepén számok
-
Mobilarena
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
válasz
Wolfram #21767 üzenetére
chatgpt mire van?
Mondjuk nem teszteltem.
#ifndef BASE_64_HPP
#define BASE_64_HPP
#include <algorithm>
#include <cstdint>
#include <stdexcept>
#include <string>
namespace base64 {
const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
template <class OutputBuffer, class InputIterator>
inline OutputBuffer encode_into(InputIterator begin, InputIterator end) {
static_assert(std::is_same<typename std::decay<decltype(*begin)>::type, char>::value
|| std::is_same<typename std::decay<decltype(*begin)>::type, unsigned char>::value
|| std::is_same<typename std::decay<decltype(*begin)>::type, uint8_t>::value);
size_t counter = 0;
uint32_t bit_stream = 0;
size_t offset = 0;
OutputBuffer encoded;
encoded.reserve(static_cast<size_t>(1.5 * static_cast<double>(std::distance(begin, end))));
while (begin != end) {
auto const num_val = static_cast<uint8_t>(*begin);
offset = 16 - counter % 3 * 8;
bit_stream += num_val << offset;
if (offset == 16) {
encoded.push_back(base64_chars[bit_stream >> 18 & 0x3f]);
}
if (offset == 8) {
encoded.push_back(base64_chars[bit_stream >> 12 & 0x3f]);
}
if (offset == 0 && counter != 3) {
encoded.push_back(base64_chars[bit_stream >> 6 & 0x3f]);
encoded.push_back(base64_chars[bit_stream & 0x3f]);
bit_stream = 0;
}
++counter;
++begin;
}
if (offset == 16) {
encoded.push_back(base64_chars[bit_stream >> 12 & 0x3f]);
encoded.push_back('=');
encoded.push_back('=');
}
if (offset == 8) {
encoded.push_back(base64_chars[bit_stream >> 6 & 0x3f]);
encoded.push_back('=');
}
return encoded;
}
inline std::string to_base64(const std::string& data) {
return encode_into<std::string>(data.begin(), data.end());
}
template <class OutputBuffer>
inline OutputBuffer decode_into(const std::string& data) {
using value_type = typename OutputBuffer::value_type;
static_assert(std::is_same<value_type, char>::value
|| std::is_same<value_type, unsigned char>::value
|| std::is_same<value_type, uint8_t>::value);
size_t counter = 0;
uint32_t bit_stream = 0;
OutputBuffer decoded;
decoded.reserve(data.size());
for (unsigned char c : data) {
auto const num_val = base64_chars.find(c);
if (num_val != std::string::npos) {
auto const offset = 18 - counter % 4 * 6;
bit_stream += static_cast<uint32_t>(num_val) << offset;
if (offset == 12) {
decoded.push_back(static_cast<value_type>(bit_stream >> 16 & 0xff));
}
if (offset == 6) {
decoded.push_back(static_cast<value_type>(bit_stream >> 8 & 0xff));
}
if (offset == 0 && counter != 4) {
decoded.push_back(static_cast<value_type>(bit_stream & 0xff));
bit_stream = 0;
}
} else if (c != '=') {
throw std::runtime_error("Invalid base64 encoded data");
}
counter++;
}
return decoded;
}
inline std::string from_base64(const std::string& data) {
return decode_into<std::string>(data);
}
} // namespace base64
#endif // BASE_64_HPP
Új hozzászólás Aktív témák
- EAFC 26
- Kormányok / autós szimulátorok topikja
- Azonnali navigációs kérdések órája
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- Kedvenc zene a mai napra
- Milyen videókártyát?
- gban: Ingyen kellene, de tegnapra
- A fociról könnyedén, egy baráti társaságban
- Ubiquiti hálózati eszközök
- Vezeték nélküli fülhallgatók
- További aktív témák...
- Eladó HP Envy x360 15-fe0178ng OLED, RTX 3050, i7-1355U, gyakorlatilag új! 3 órát ment eddig
- DELL latitude 5410 Tartós Üzleti Laptop 14" -70% i5-10210U 4Mag 8Gb 256GB SSD FHD IPS
- Eladó Dobozos Új ASUS TUF A15 Gaming Laptop
- Gamer PC i5-12400F, RTX 4060, 16 GB DDR5, 1 TB NVMe kiváló állapot(1 éves)! 410.000 Ft
- DELL latitude 5410 Tartós Üzleti Laptop 14" -70% i5-8365U 4Mag 8Gb 256GB SSD FHD IPS
- Törött Apple iMac 19.2 i5-8500 Radeon Pro 560X 4GB 16GB 256GB SSD 21.5" 4K Retina
- ÁRGARANCIA!Épített KomPhone i9 14900KF 64GB RAM RTX 5090 32GB GAMER PC termékbeszámítással
- HIBÁTLAN iPhone 13 mini 128GB Starlight -1 ÉV GARANCIA -Kártyafüggetlen, MS3611, 94% Akkumulátor
- Braun KF 47/1 tea és kávéfőző fehér / 12 hó jótállás
- BESZÁMÍTÁS! ASUS B760M i5 12400F 32GB DDR4 1TB SSD RTX 3070Ti 8GB Fractal Design R5 FSP 850W
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest