Skip to main content

getAESEncryptedString, getAESDecryptedString

  • It is utility functions for encrypting and decrypting strings using AES (Advanced Encryption Standard).
  • These utilities are useful for securely handling sensitive data, such as user credentials or configuration values.

Functions

  1. getAESEncryptedString(value)

    • Description: Encrypts a given string using AES encryption.
    • Parameters:
      • value (string): The string to encrypt. Defaults to an empty string if not provided.
    • Returns:
      • An encrypted string if value is not empty.
      • null if value is empty.
  2. getAESDecryptedString(value)

    • Description: Decrypts an AES-encrypted string back to its original value.
    • Parameters:
      • value (string): The encrypted string to decrypt. Defaults to an empty string if not provided.
    • Returns:
      • The decrypted string if value is not empty and valid.
      • null if value is empty or invalid.

Usage Example

const { protrakComponents } = React.useContext(customWidgetContext);
const { TextBox } = protrakComponents;

const secretData = 'SensitiveInformation';

// Encrypt the data
const encryptedData = getAESEncryptedString(secretData);
console.log('Encrypted:', encryptedData);

// Decrypt the data
const decryptedData = getAESDecryptedString(encryptedData);
console.log('Decrypted:', decryptedData);