Combine Files fstream is fast and is good for combining large files together without needing to read in each file. Combine 2 files (can be any file type): #include <fstream> std::ifstream ifstream1("a.bin", std::ios_base::binary); std::ifstream ifstream2("b.bin", std::ios_base::binary); std::ofstream ofstream1("c.bin", std::ios_base::binary); ofstream1 << ifstream1.rdbuf() << ifstream2.rdbuf(); Adding some bytes to the output file: BYTE MyByteArray[3]; MyByteArray[0] = 0x01; MyByteArray[0] = […]
All posts by
Encrypting Files with openssl
Good resources https://linuxconfig.org/using-openssl-to-encrypt-messages-and-files-on-linux Public key encrypt / private key decrypt – RSA (small files) Note RSA (rsault) is only suitable for very small files and is typically used to encrypt a randomly chosen private key that a larger file gets encrypted with. The reason it won't allow use with large files (say over around 512 bytes) […]
Signing Files With SHA256
SHA256 is widely regarded as a good security hash that's still secure (some others such as MD5 etc are no longer considered secure). The following process lets you sign and verify files using sha256 Raspbian comes with openssl already and the commands used below are console commands If you want to execute them programmatically you can use the approach […]
USB Drives
Mount A USB Memory Stick / Drive List available devices ls -l /dev/disk/by-uuid/ SDA1 will be your USB memory stick (unless you have multiple). What it means: The SD means SCSI device which also incoporates USB drives. The A means the 1st drive found (the next would be SDB, SDC, etc) The 1 means the first partition of the […]
Disk Space
Used Space On Disk df -h To get the amount of free space on the disk as a single value in kB you can use this: df -k /tmp | tail -1 | awk '{print $4}' or in MB: df -BM /tmp | tail -1 | awk '{print $4}' (info about this here) Used Space Of Current […]
Duplicating SD Cards
One by one win32diskimager Batch Duplication – Commercial We've not tried it but the "Vinpower Digital SD Shark Standalone Target SD/MicroSD Memory Card Duplicator" looks as though it might be a more reasonably priced solution (still pretty expensive though). It's stocked by quite a few retailers including amazon. We asked if it would work for […]
C or C++ Libraries
Installing the correct version of a C/C++library Often a library will have a seperate install for C or C++ and you need to install the correct one! Sounds obvious but with so many libraries having poor documentation this can be a simple thing that consfuses the hell out of you. Take for instance the libconfig library: The […]
.libconfig general
Libconfig is a simple compact library for processing structured configuration files. The file format is more compact and more readable than XML and unlike XML, it is type-aware, so it is not necessary to do string parsing in application code. Resources Libconfig homepage
Using libconfig in a C++ project
Installing Use the following to install the library on your Raspberry Pi: sudo apt-get install libconfig++-dev Using #include <libconfig.h++> //This library needs the "-lconfig++" adding to Project Properties > Build > Linker > Libraries using namespace libconfig;
Using libconfig in a C project
Installing Use the following to install the library on your Raspberry Pi: sudo apt-get install libconfig-dev Using #include <libconfig.h> //This library needs the "-lconfig" adding to Project Properties > Build > Linker > Libraries