'Attempt to encrypt a plaintext credential.
:param credential: a plaintext representation of a credential
:returns: an encrypted credential'

def encrypt(self, credential):

    (crypto, keys) = get_multi_fernet_keys()
    if (keys[0] == fernet_utils.NULL_KEY):
        LOG.warning('Encrypting    credentials    with    the    null    key.    Please    properly    encrypt    credentials    using    `keystone-manage    credential_setup`,    `keystone-manage    credential_migrate`,    and    `keystone-manage    credential_rotate`')
    try:
        return (crypto.encrypt(credential.encode('utf-8')), primary_key_hash(keys))
    except (TypeError, ValueError) as e:
        msg = (_('Credential    could    not    be    encrypted:    %s') % str(e))
        LOG.error(msg)
        raise exception.CredentialEncryptionError(msg)
