1. Hashtag Helpers
  2. PKC Decrypt

Hashtag Helpers

PKC Decrypt

Decrypts data that was encrypted with the pkc_encrypt helper

This hashtag helper decrypts data that was previously encrypted using the pkc_encrypt helper. The decryption is performed based on the service and identifier restrictions that were applied during encryption.

NOTE

In most cases, you won't need to use this helper directly. The system automatically applies it when encrypting data. This documentation is provided for completeness and to help understand how the encryption/decryption process works.

Uses

  • Decrypt sensitive data that was encrypted with pkc_encrypt
  • Access encrypted information within the appropriate service context
  • Retrieve sensitive information only when the correct identifier is being used

Usage

Helper name: pkc_decrypt

Arguments

Position Description
1 (Optional) Service that is allowed to decrypt (e.g. 'whatsapp', 'apicall')
2 (Optional) Identifier within the service (e.g. phone number for WhatsApp, URL for API Call)

Parameters

Position Description
1 Encrypted value to be decrypted

eg. ~~#pkc_decrypt#encrypted_data or ~~#pkc_decrypt 'service_name'#encrypted_data or ~~#pkc_decrypt 'service_name' 'identifier'#encrypted_data

How It Works

When data is encrypted using pkc_encrypt, the system automatically generates a pkc_decrypt helper with the appropriate service and identifier restrictions. This encrypted data is typically stored in a task result or other location.

When you reference this encrypted data in a substitution, the system will:

  1. Check if the current service matches the service restriction (if any)
  2. Check if the current identifier matches the identifier restriction (if any)
  3. Decrypt the data only if all restrictions are satisfied

Examples

Basic Usage

In most cases, you'll simply reference the encrypted data using a standard substitution path:

loading...

In this example, if stubpost.tasks.my_task.payload.secret_pin contains encrypted data, the system will automatically attempt to decrypt it based on the service and identifier restrictions.

Understanding the Encrypted Format

When data is encrypted with pkc_encrypt, it's transformed into a format like this:

        ~~#target 'whatsapp'#~~#pkc_decrypt 'whatsapp' '~~__identifier'#Je6BAeYgT1myQvPAgofBhkHudDSrFpvPrGhBCs52khtPjZ602JEyP8rmtkHKsmTQR7sP+kQRZyb67EOitlEG7Yli+IEaUUc6S9aILcRK0VtuS5gMt8CpyS1IzUXCRx0MSCoId7kAiG7OvH8M3K/ysWWOup8QmP6jZwcS5BLXuaZQPBvsNesbKyEyW31gQuZRDjSKTl27wstAK2OKVLci/qUTE+4cxcjHmp7lJzIMW4DdwoAW6TNlNXM5JsxF8jyUiS5+AmmApRi0wpXDBY/Xe4vLMzlX53ht+gW7CpDpZkUXx59PTuY4Qt6AOoe0JX5sJDkg4oKZd+7eunUS5GJxVA==

      

This includes:

  • A target helper to ensure the decryption is only attempted by the appropriate service
  • A pkc_decrypt helper with service and identifier restrictions
  • The actual encrypted data

Decryption Scenarios

Unrestricted Decryption

If data was encrypted without service or identifier restrictions, any service can decrypt it:

        ~~#pkc_decrypt#encrypted_data

      

Service-Restricted Decryption

If data was encrypted for a specific service, only that service can decrypt it:

        ~~#pkc_decrypt 'whatsapp'#encrypted_data

      

Service and Identifier-Restricted Decryption

If data was encrypted for a specific service and identifier, only that service using that identifier can decrypt it:

        ~~#pkc_decrypt 'whatsapp' '27713334444'#encrypted_data

      

Special Identifier Syntax

When using the pkc_encrypt helper with an identifier, the system will often use the special ~~__identifier syntax in the resulting encrypted data. This is a placeholder that gets replaced with the actual identifier at runtime.

For example, in WhatsApp, ~~__identifier will be replaced with the phone number being used for the message.

Practical Example

Here's a complete workflow example:

  1. Encrypt data in an API Call task:
loading...
  1. The API Call result contains the encrypted data:
loading...
  1. Use the encrypted data in a WhatsApp message:
loading...
  1. The WhatsApp service will decrypt the data only when sending to the specified phone number:
loading...
NOTE

If the WhatsApp service tries to send the message to any phone number other than 27713334444, the decryption will fail, and the message will not contain the sensitive data.

TIP

For most use cases, you don't need to manually use the pkc_decrypt helper. Simply reference the encrypted data using standard substitution, and the system will handle the decryption automatically if the service and identifier restrictions are satisfied.