Added unit test and encrytption logic