Implement and Fix encryption algorithm