Fixed error checks in encryption functions.