MCPcopy Create free account
hub / github.com/blizzard4591/openMittsu / decodeBase32Sequence

Method decodeBase32Sequence

src/encoding/Base32.cpp:42–63  ·  view source on GitHub ↗

this function assumes that the amount of decoded Characters is always a multiple of 8 Base32 Characters (so that the output forms a full number of Bytes)

Source from the content-addressed store, hash-verified

40
41 // this function assumes that the amount of decoded Characters is always a multiple of 8 Base32 Characters (so that the output forms a full number of Bytes)
42 QByteArray Base32::decodeBase32Sequence(QString const& source) {
43 QByteArray result;
44 size_t usedBits = 0;
45 char value = 0;
46 uint_fast32_t cache = 0;
47 const int sourceLength = source.size();
48 for (int i = 0; i < sourceLength; ++i) {
49 if (!isCharacterOfBase32Encoding(source.at(i))) {
50 continue;
51 }
52
53 value = convertCharTo5BitValue(source.at(i));
54 cache = (cache << 5) | value;
55 usedBits += 5;
56
57 while (usedBits >= 8) {
58 result.append((cache >> (usedBits - 8)) & 0xFF);
59 usedBits -= 8;
60 }
61 }
62 return result;
63 }
64
65 QString Base32::encodeBase32Sequence(QByteArray const& source, bool formatString) {
66 QString result;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected