Encrypting data

Hi @Meme_Bomber,

To achieve this in a JavaScript environment, you would generally follow these steps:

  1. PGP Encryption:
  • You can use a library like OpenPGP.js to encrypt your data with your PGP public key. This ensures that only you can decrypt it with your private key.
  1. AES-256 Encryption:
  • If you want to add an additional layer of encryption, you can first encrypt the data with AES-256 and then encrypt the AES key with your PGP public key. Libraries like CryptoJS can help with AES encryption in JavaScript.

Here’s a very basic example of how you might approach this:

import * as openpgp from 'openpgp'
import CryptoJS from 'crypto-js'

// Example of AES encryption
const aesEncrypt = (data, secretKey) => {
  return CryptoJS.AES.encrypt(data, secretKey).toString()
}

// Example of PGP encryption
const pgpEncrypt = async (data, publicKey) => {
  const encrypted = await openpgp.encrypt({
    message: await openpgp.createMessage({ text: data }),
    encryptionKeys: publicKey,
  })

  return encrypted
}

// Encrypt your data first with AES
const aesEncryptedData = aesEncrypt('Your sensitive data', 'YourAESSecretKey')

// Then encrypt the AES key with PGP
const pgpEncryptedAESKey = await pgpEncrypt('YourAESSecretKey', 'YourPGPPublicKey')

Note: To implement this with Codeless logic, you would need to use a Custom Code block to handle the encryption.

Hope this is helpful and gives you some direction.

Regards,
Stanislaw