Encryption and decryption algorithm