fixed null pointer at the encrypt