Monday, February 16, 2015

Using boost.property_tree.ptree to store JSON data

A Property Tree in Boost is a data structure that can store information in a tree-like format. Each node having a key and a value. It can be used to store XML, INI, INFO and JSON formats. Maybe also other, but these are the most popular and they are supported by boost, with ready-to-use parsers.
The limitation for JSON handling, is that property trees do not support simple arrays, since all nodes are of key-value type.



Friday, February 13, 2015

Boost.Asio HTTPS client

The boost asio official documentation gives two examples of making HTTP requests and using SSL for a connection. However, none of these examples do a HTTPS GET request.
In other words, if you want to make a HTTP GET request over a secure connection, you need to combine the two examples.
The links to the examples are http client and ssl client.



Monday, February 9, 2015

How to generate a SHA1 hash in C++

Having been put in the position of generating password hashes (again), I thought I better write it down for posterity.
You can always write your own SHA1 implementation, but let's be serious, who wants that? Unless you're doing it for academic purposes, it makes no sense to reinvent the wheel when there are so many good implementations out there.

Among all the available libraries I chose to experiment with OpenSSL and boost.