MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / base64

Function base64

src/common/utils.cpp:1660–1685  ·  view source on GitHub ↗

converts bytes to BASE64 representation

Source from the content-addressed store, hash-verified

1658
1659// converts bytes to BASE64 representation
1660void base64(Firebird::string& b64, const Firebird::UCharBuffer& bin)
1661{
1662 b64.erase();
1663 const unsigned char* f = bin.begin();
1664 for (int i = bin.getCount(); i > 0; i -= 3, f += 3)
1665 {
1666 if (i >= 3)
1667 {
1668 const ULONG l = (ULONG(f[0]) << 16) | (ULONG(f[1]) << 8) | f[2];
1669 b64 += conv_bin2ascii(l >> 18);
1670 b64 += conv_bin2ascii(l >> 12);
1671 b64 += conv_bin2ascii(l >> 6);
1672 b64 += conv_bin2ascii(l);
1673 }
1674 else
1675 {
1676 ULONG l = ULONG(f[0]) << 16;
1677 if (i == 2)
1678 l |= (ULONG(f[1]) << 8);
1679 b64 += conv_bin2ascii(l >> 18);
1680 b64 += conv_bin2ascii(l >> 12);
1681 b64 += (i == 1 ? '=' : conv_bin2ascii(l >> 6));
1682 b64 += '=';
1683 }
1684 }
1685}
1686
1687void random64(Firebird::string& randomValue, FB_SIZE_T length)
1688{

Callers 3

random64Function · 0.85
hashBased64Method · 0.85
hashBased64Function · 0.85

Calls 5

ULONGEnum · 0.85
conv_bin2asciiFunction · 0.85
eraseMethod · 0.45
beginMethod · 0.45
getCountMethod · 0.45

Tested by

no test coverage detected