Skip to main content
A Python SDK for platform encryption operations, providing secure encryption and decryption capabilities.
Related Links

Pre-requisites

1

Request repository access to the Packages

Reach out to Platform team to request access to the Packages repository:
2

Requirements

  • Python 3.7+
  • API & Secret Key
  • Reach out to Platform team for any assistance.
      You can generate an API and Secret Key using the Encryption Service APIs. Refer to the API Reference for further details.

    Installation

    pip install git+https://github.com/LocAI1/platform-encryption-python-sdk.git
    
    If you encounter an HTTP 404 error, please follow these steps:
    brew install gh
    gh auth login
    pip install git+https://github.com/LocAI1/platform-encryption-python-sdk.git
    

    Usage

    See the example below or check example.py for detailed usage:
    
    
    import asyncio
    
    from encrova_sdk.EncrovaSDKClient import EncrovaSDKClient
    
    async def main():
        """
        Demonstrates the usage of Encrova SDK for encryption and decryption
        operations.
    
        The example shows:
        1. Initializing the Encrova SDK client with symmetric or asymmetric encryption
        2. Encrypting a JSON payload containing identity provider configurations
        3. Decrypting the encrypted JWE (JSON Web Encryption) token
        """
    
        # Initialize Encrova SDK client with symmetric or asymmetric encryption mode
        # encryption_type can be either "symmetric" or "asymmetric"
        encrova_client = EncrovaSDKClient(
                    host="http://localhost:8000",
                    encryption_type="symmetric"
        )
    
        # Encrypt a JSON payload using the encrypt API
        # Parameters:
        # - payload: JSON object containing the data to be encrypted
        # - api_key: API key for authentication
        # - secret_key: Secret key used for encryption
        jwe = await encrova_client.service.encrypt(
            payload={"username" : "udayakumar.rajan", "password" : "random"},
            api_key="<API Key>",
            secret_key="<Secret Key>"
        )
        print(f"jwe : {jwe}")
    
        # Decrypt the JWE token using the decrypt API
        # Parameters:
        # - jwe: The encrypted JWE token to be decrypted
        # - api_key: API key for authentication
        plaintext = await encrova_client.service.decrypt(
            jwe=jwe,
            api_key="<API Key>"
        )
        print(f"plain text : {plaintext}")
    
    
    """ Run the async main function """
    if __name__ == "__main__":
        asyncio.run(main())