def encrypt_string(self, concatenated_str):
        """Timestamp, sign and encrypt a string into a token using ``cryptography.fernet.Fernet()``."""

        # Convert string to bytes
        concatenated_bytes = concatenated_str.encode()

        # Encrypt, timestamp, sign, and base64-encode
        encrypted_bytes = self.fernet.encrypt(concatenated_bytes)

        # Convert bytes to string
        encrypted_str = encrypted_bytes.decode('utf-8')

        # Remove '=' padding if needed
        token_str = encrypted_str.strip('=')
        return token_str
def encrypt_string ( self , concatenated_str ) : concatenated_bytes = concatenated_str . encode ( ) encrypted_bytes = self . fernet . encrypt ( concatenated_bytes ) encrypted_str = encrypted_bytes . decode ( 'utf-8' ) token_str = encrypted_str . strip ( '=' ) return token_str
Timestamp, sign and encrypt a string into a token using ``cryptography.fernet.Fernet()``.