Encrypting Data

Encrypting Data

The Vortex Crypto API provides a comprehensive encryption solution that ensures the security of your data. Upon encrypting data, the API returns an encrypted object alongside a hash and mask field. The hashing is performed using the API's HMAC algorithm, which guarantees the integrity and authenticity of your data.

Masking Algorithm

The masking feature offers additional security by revealing only a portion of the encrypted string, based on its length:

  • For strings of 9 characters or more: the last 4 characters are returned.
  • For strings of 5 to 8 characters in length: the last 2 characters are returned.
  • For strings shorter than 5 characters: no characters are returned.

This algorithm ensures a balance between security and the need for partial data visibility.

Encryption Example

When you encrypt data using the Vortex Crypto API, the response includes the encrypted data, a hash value representing the data's integrity, and a mask derived from the encrypted string.

Encryption Response Example:

{
  "data": {
    "key": 1234567,
    "iv": null,
    "data": "c29tZSBlbmNyeXB0ZWQgZGF0YQ==",
    "encoding": "utf8"
  },
  "hash": "c29tZSBoYXNoIHZhbHVl",
  "mask": "1234"
}

In this example, data is the base64 encoded string of the encrypted data. The key and iv (initialization vector) are used in the encryption process, though iv may be null depending on the encryption method used. The hash provides a HMAC hash of the encrypted data, ensuring its integrity, and the mask shows the last few characters of the encrypted string, as defined by the masking algorithm.