Added some sample code to also handle encryption