Fixed potential null reference exceptions in Encryption functions.