Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FEATURE] PPL Add Cryptographic hash function in eval and where command #3276

Open
acarbonetto opened this issue Jan 29, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@acarbonetto
Copy link
Collaborator

acarbonetto commented Jan 29, 2025

Is your feature request related to a problem?
Similar to opensearch-project/opensearch-spark#759

Cryptographic functions like sha1 or md5 are not available in OpenSearch PPL and could be added. See the Splunk reference library for examples https://docs.splunk.com/Documentation/SCS/current/SearchReference/CryptographicFunctions

Examples:

### `MD5`

**Description**

Calculates the MD5 digest and returns the value as a 32 character hex string.

Usage: `md5('hello')`

- Argument type: STRING
- Return type: STRING

Example:

    os> source=people | eval `MD5('hello')` = MD5('hello') | fields `MD5('hello')`
    fetched rows / total rows = 1/1
    +----------------------------------+
    | MD5('hello')                     |
    |----------------------------------|
    | 5d41402abc4b2a76b9719d911017c592 |
    +----------------------------------+

### `SHA1`

**Description**

Returns the hex string result of SHA-1

Usage: `sha1('hello')`

- Argument type: STRING
- Return type: STRING

Example:

    os> source=people | eval `SHA1('hello')` = SHA1('hello') | fields `SHA1('hello')`
    fetched rows / total rows = 1/1
    +------------------------------------------+
    | SHA1('hello')                            |
    |------------------------------------------|
    | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |
    +------------------------------------------+

### `SHA2`

**Description**

Returns the hex string result of SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, and SHA-512). The numBits indicates the desired bit length of the result, which must have a value of 224, 256, 384, 512

Usage: `sha2('hello',256)`

Usage: `sha2('hello',512)`

- Argument type: STRING, INTEGER
- Return type: STRING

Example:

    os> source=people | eval `SHA2('hello',256)` = SHA2('hello',256) | fields `SHA2('hello',256)`
    fetched rows / total rows = 1/1
    +------------------------------------------------------------------+
    | SHA2('hello',256)                                                |
    |------------------------------------------------------------------|
    | 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 |
    +------------------------------------------------------------------+

    os> source=people | eval `SHA2('hello',512)` = SHA2('hello',512) | fields `SHA2('hello',512)`
    fetched rows / total rows = 1/1
    +----------------------------------------------------------------------------------------------------------------------------------+
    | SHA2('hello',512)                                                                                                                |
    |----------------------------------------------------------------------------------------------------------------------------------|
    | 9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043 |
    +----------------------------------------------------------------------------------------------------------------------------------+

Do you have any additional context?

@acarbonetto acarbonetto added enhancement New feature or request untriaged labels Jan 29, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants