How is your experience with the OutSystems Community?
16
Views
6
Comments
encyrpt AES hexadecimal

Hi,


 how can I implement AES encryption with hexadecimal output?


2023-12-26 10-35-28
OutSystems Neo
Staff
AI Generated

You can do it in two steps:

  1. Encrypt with AES (using the CryptoAPI extension).
  2. Convert the resulting binary to Hex (using BinaryData).

1. Encrypt with AES

  • Add the CryptoAPI extension to your module.
  • Use the server action CryptoAPI_AES_Encrypt (name may vary slightly depending on version).
  • Inputs typically are:
    • PlainText (Text)
    • Password / Key (Text or Binary, depending on which action you use)
    • Optional: Salt, IV, Iterations, etc.
  • The action usually returns a Binary output (EncryptedData) or a Base64 Text, depending on the CryptoAPI version you’re using. If it returns Base64 Text, convert it to Binary first with BinaryData\Base64ToBinary.

Example (server action flow):

PlainText (Text) → CryptoAPI_AES_Encrypt → EncryptedBinary (Binary)

If the encrypt action returns text (Base64):

PlainText → CryptoAPI_AES_Encrypt (returns Base64Text)
          → Base64ToBinary(Base64Text) = EncryptedBinary

2. Convert AES result to Hex

Use the BinaryData extension:

  • Call BinaryToHex with the AES binary output.
  • The result is a Text containing only [0-9A-F], which is what you want.

Example (continuing the flow):

EncryptedBinary → BinaryToHex → EncryptedHex (Text)

Now EncryptedHex is your AES-encrypted value in hexadecimal format (no special characters).

3. Decrypt from Hex back to original text

To decrypt, reverse the process:

  1. Hex to Binary: use HexToBinary(EncryptedHex).
  2. AES Decrypt: call CryptoAPI_AES_Decrypt with that Binary (and the same key/parameters).

Example (server action flow):

EncryptedHex (Text)
  → HexToBinary = EncryptedBinary (Binary)
  → CryptoAPI_AES_Decrypt(EncryptedBinary, Password/Key, …)
  → PlainText (Text)

This pattern is aligned with how AES + hex is usually suggested in OutSystems (encrypt with AES, then format with Hex instead of Base64). SH1 Encrypt with key

This answer was AI-generated. Please read it carefully and use the forums for clarifications
2023-06-21 08-58-47
Andrew Mahfouz 
i need url for this Use the BinaryData extension:

2023-12-26 10-35-28
OutSystems Neo
Staff
AI Generated

You can find the BinaryData extension (system component) documentation and download page here:

BinaryData (System Components):
https://www.outsystems.com/forge/component-overview/4511/binarydata BinaryData

After you add it from Forge to your environment, open your module in Service Studio, go to Logic > Dependencies, search for BinaryData, and add it so you can use actions like BinaryDataToHex. BinaryData API

This answer was AI-generated. Please read it carefully and use the forums for clarifications
2023-09-06 07-26-35
Sudip Pal

Hi @Andrew Mahfouz  

Is this issue resolved? If not, shall I share an OML to help you?

Thanks,

Sudip

2023-06-21 08-58-47
Andrew Mahfouz 

Can you share oml

2023-09-06 07-26-35
Sudip Pal

Hey @Andrew Mahfouz  

Try the below OML and let me know if you need some help. But before that you need to install the below component from Forge

Thanks,

Sudip

AESEncryption.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.