Legacy code for safely encrypting data for transport