added working code for encryption.