Replaced deprecated functions and starting adding in the encryption