Skip to content

[Smart Hashing] Add smart hashing documentation in readme #2860

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

harsh-joshi99
Copy link
Contributor

@harsh-joshi99 harsh-joshi99 commented Apr 8, 2025

Adds documentation about the new smart hashing module.

Testing

N/R: Documentation changes only.

Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

@harsh-joshi99 harsh-joshi99 marked this pull request as ready for review April 9, 2025 10:01
README.md Outdated
Comment on lines 969 to 973
### Key Benefits

- **Automatic Hashing Detection**: Avoids double-hashing by identifying already hashed values.
- **Consistent Hashing**: Applies the correct algorithm and format across use cases.
- **Optional Input Normalization**: Supports custom logic for cleaning and standardizing inputs (e.g., trimming, formatting).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is not needed.

Suggested change
### Key Benefits
- **Automatic Hashing Detection**: Avoids double-hashing by identifying already hashed values.
- **Consistent Hashing**: Applies the correct algorithm and format across use cases.
- **Optional Input Normalization**: Supports custom logic for cleaning and standardizing inputs (e.g., trimming, formatting).

README.md Outdated
Comment on lines 965 to 967
Use the `processHashing` utility to hash Personally Identifiable Information (PII)—like email addresses and phone numbers.

This utility simplifies workflows by automatically detecting and handling pre-hashed values, ensuring compatibility across destinations and preventing common data-matching issues.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use the `processHashing` utility to hash Personally Identifiable Information (PII)—like email addresses and phone numbers.
This utility simplifies workflows by automatically detecting and handling pre-hashed values, ensuring compatibility across destinations and preventing common data-matching issues.
Our popular segment Adtect destinations support [automatic hash detection](https://segment.com/docs/connections/destinations/#hashing) of personally identifyable information (PII). If your destination hashes PII data, we recommend you use the `processHashing` utility instead of `createHash` from `crypto` module.
The `processHashing` utility supports `md5`, `sha1`,`sha224`,`sha256`,`sha384` and`sha512` hashing algorithms. It can output digests in `hex` or `base64` format.
**Note**: For empty or whitespace-only strings, the `processHashing` outputs an empty string instead of throwing an error like `createHash` hash module.

Comment on lines +1056 to +1059

```

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
```

README.md Outdated
Comment on lines 1007 to 1024
### Notes

**Empty Input Handling**: Returns `''` for empty or whitespace-only strings.

**Supported Hash Algorithms**

- `md5`
- `sha1`
- `sha224`
- `sha256`
- `sha384`
- `sha512`

All algorithms support `hex` and `base64` digest formats.

**Requesting Additional Algorithms**
To request additional hash algorithms, contact [email protected].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Notes
**Empty Input Handling**: Returns `''` for empty or whitespace-only strings.
**Supported Hash Algorithms**
- `md5`
- `sha1`
- `sha224`
- `sha256`
- `sha384`
- `sha512`
All algorithms support `hex` and `base64` digest formats.
**Requesting Additional Algorithms**
To request additional hash algorithms, contact [email protected].
### Notes
**Empty Input Handling**: Returns `''` for empty or whitespace-only strings.
**Supported Hash Algorithms**
- `md5`
- `sha1`
- `sha224`
- `sha256`
- `sha384`
- `sha512`
All algorithms support `hex` and `base64` digest formats.
**Requesting Additional Algorithms**
To request additional hash algorithms, contact [email protected].

@@ -960,6 +960,49 @@ There are a few subtle differences from the Fetch API which are meant to limit t
- some options and behaviors are not applicable to Node.js and will be ignored by `node-fetch`. See this list of [known differences](https://github.com/node-fetch/node-fetch/blob/1780f5ae89107ded4f232f43219ab0e548b0647c/docs/v2-LIMITS.md).
- `method` will automatically get upcased for consistency.

## Automatic Hashing Detection with `processHashing`

Our popular segment Adtect destinations support [automatic hash detection](https://segment.com/docs/connections/destinations/#hashing) of personally identifyable information (PII). If your destination hashes PII data, we recommend you use the `processHashing` utility instead of `createHash` from `crypto` module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder should we explicitly say that this feature will detect if a string is already hashed, and will only apply a hash if the string is not already hashed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants