algorithm for performing encryption or decryption