Fixed errors in encrypt and decrypt functions