FBB::I...Stream(3bobcat)
π NAME π
okay so this whole page is FBB::I...Stream(3bobcat) β Symmetric en- and decryption β and the actual star of the show is:
FBB::ISymCryptStream β an Istream that performs symmetric en/decryption. yes bestie, an input stream that justβ¦ encrypts or decrypts as it goes. iconic behavior fr fr. π
πΈ SYNOPSIS πΈ
#include <bobcat/isymcryptstream>
Linking option: -lbobcat -lcrypto
π¦ DESCRIPTION π¦
so basically: FBB::ISymCryptStream objects are your little guys for encrypting or decrypting info that lives on separate std::istream streams. no cap.
ISymCryptStream is a class template, and it takes a FBB::CryptType template non-type parameter. so:
- objects of the class
FBB::ISymCryptStream<FBB::ENCRYPT>encrypt whatever they receive π - objects of the class
FBB::ISymCryptStream<FBB::DECRYPT>decrypt whatever they receive π
Every symmetric encryption method that the OpenSSL library defines, as long as it can be selected by name, may be used to en/decrypt your stuff. to pick a particular encryption method you pass an identifier to the constructor. like, for example, "aes-256-gcm". and if you wanna see an overview of the currently supported cipher algorithms, run this lil command:
openssl list -cipher-algorithms
ISymCryptStream objects read the info they're gonna en/decrypt from std::istream objects β and those get specified at construction time, either as istream references or by filename. the characters that get extracted or read from the ISymCryptStream objects are then en/decrypted, and could, for example, be written to some output stream. π
π NAMESPACE π
FBB
All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. (iykyk β everything lives in FBB.)
π INHERITS FROM π
FBB::ISymCryptStreambuf(private) β privately, bestie, don't get any ideasstd::istream
β¨ CONSTRUCTORS β¨
ISymCryptStream<CryptType>(std::istream &inStream, std::string const &cipherName, std::string const &key, std::string const &iv, size_t inBufSize = 100)β this constructor defines astd::istreamobject that encrypts or decrypts the characters which are read frominStream. πISymCryptStream<FBB::ENCRYPT>objects perform encryption;ISymCryptStream<FBB::DECRYPT>objects perform decryption;ISymCryptStream<CryptType>objects receive the characters to encrypt or decrypt frominStream;- the encryption method to use is specified by the
cipherNameparameter. e.g.,"AES-256-GCM"; - the symmetric key to use is specified by the
keyparameter; - the initialization vector is specified by the
ivparameter; - the
FBB::ISymCryptStreambufinternally used buffer will holdinBufSizecharacters. the default value is the smallest value that is used. and heads up: when you specify a smallerbufSizevalue than the default value, then the default value is used. (so it doesn't go under, it just snaps back to the default π);
ISymCryptStream<CryptType>(std::string const &inStreamName, std::string const &cipherName, std::string const &key, std::string const &iv, size_t inBufSize = 100)β same constructor as the one above, but this constructor's first parameter specifies the name of the file containing the characters to encrypt or decrypt. π«Ά
β οΈ if the construction fails, an exception is thrown, mentioning the openssl function that failed to complete (see also errorMsg below).
the move constructor is available. the copy constructor and assignment operators are not available. (gatekeeping, but for safety πΈ)
π INHERITED MEMBERS π
since the class is publicly derived from std::istream, all std::istream members can be used. yes, all of them. periodt.
π MEMBER FUNCTIONS π
static std::string errorMsg()β if an openssl function fails, an exception is thrown mentioning the name of the failing function. in those cases the functionerrorMsgcan be called, returning astd::stringcontaining the openssl error code (returned byERR_get_error) and its textual representation (returned byERR_error_string). and if the reported error code is zero, then likeβ¦ in fact no error has occurred and the exception was spuriously reported. πstatic size_t keyLength(std::string const &cipherName)β returns the minimum key length that's required for ciphercipherName. πstatic size_t ivLength(std::sting const &cipherName)β returns the minimum length of the initialization vector that's required for ciphercipherName. (yes, it really saysstd::stingup there. we're just relaying the lore, bestie. π)
the latter two functions throw exceptions if cipherName does not contain the name of a supported cipher algorithm.
π₯ EXAMPLE π₯
#include <iostream>
#include <fstream>
#include <string>
#include <bobcat/isymcryptstream>
#include <bobcat/isymcryptstreambuf>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
try
{
if (argc == 1)
{
cout << "arg[1]: e - encrypt, d - decrypt,\n"
"arg[2]: file to process, arg[3]: processed file\n";
return 0;
}
string key = "0123456789abcdef0123456789abcdef";
string iv = " 0123456789ab" "456";
char cipherName[] =
"AES-256-GCM"
//"AES-256-CBC"
;
ifstream in = Exception::factory<ifstream>(argv[2]);
ofstream out{ argv[3] };
ISymCryptStreambuf<ENCRYPT> encbuf{ in, cipherName, key, iv, 100 };
if (*argv[1] == βeβ)
{
ISymCryptStream<ENCRYPT> enc{ in, cipherName, key, iv, 100 };
// comment out the previous line and uncomment the next
// to use the constructor expecting a string as 1st arg:
// ISymCryptStream<ENCRYPT> enc{ argv[2], cipherName, key,
// iv, 100};
out << enc.rdbuf();
}
else
{
ISymCryptStream<DECRYPT> decrypt{ in, cipherName, key, iv, 100 };
// comment out the previous line and uncomment the next
// to use the constructor expecting a string as 1st arg:
// ISymCryptStream<DECRYPT> decrypt{ argv[2], cipherName, key,
// iv, 100 };
out << decrypt.rdbuf();
}
}
catch (exception const &exc)
{
cerr << exc.what() << β\nβ;
}
π§ FILES π§
bobcat/isymcryptstreamβ defines the class interface
β SEE ALSO β
bobcat(7), isymcryptstreambuf(3bobcat), osymcryptstream(3bobcat), osymcryptstreambuf(3bobcat)
π BUGS π
None Reported. (we love a clean slate πβ¨)
π«Ά BOBCAT PROJECT FILES π«Ά
https://fbb-git.gitlab.io/bobcat/β gitlab project page;
Debian Bobcat project files:
libbobcat6β debian package containing the shared library, changelog and copyright note;libbobcat-devβ debian package containing the static library, headers, manual pages, and developer info;
π BOBCAT π
Bobcat is an acronym of Brokkenβs Own Base Classes And Templates. (a backronym that ATE, honestly π)
π COPYRIGHT π
This is free software, distributed under the terms of the GNU General Public License (GPL).
πΈ AUTHOR πΈ
Frank B. Brokken (f.b.brokken@rug.nl).
okay that's the whole page, bestie, you're officially fluent in ISymCryptStream π
β¨ this lil gem ships as part of libbobcat-dev version 6.15.01, dated 2005-2026, and it's filed under FBB::I...Stream(3bobcat) β go forth and encrypt responsibly π¦ππ
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms