Updated Encryption Implementation with latest code