Skip to content

Commit f8cfffa

Browse files
committed
clarify using Base64 value for UID2
1 parent 142de2c commit f8cfffa

File tree

2 files changed

+89
-10
lines changed

2 files changed

+89
-10
lines changed

docs/getting-started/gs-normalization-encoding.md

Lines changed: 85 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,21 @@ For examples of various scenarios, see [Normalization Examples for Email](#norma
5858

5959
An email hash is a Base64-encoded <Link href="../ref-info/glossary-uid#gl-sha-256">SHA-256</Link> hash of a normalized email address. The email address is first normalized, then hashed using the SHA-256 hashing algorithm, and then the resulting bytes of the hash value are encoded using Base64 encoding. Note that the Base64 encoding is applied to the bytes of the hash value, not the hex-encoded string representation.
6060

61+
The following table shows an example of a simple input phone number, and the result as each step is applied to arrive at a secure, opaque, URL-safe value.
62+
63+
The final value, the hex to Base64 encoded representation of the SHA-256 hash, is the value to provide to the UID2 Operator endpoint.
64+
65+
:::warning
66+
When applying Base64 encoding, be sure to Base64-encode the raw bytes of the hash or use a Base64 encoder that takes a hex-encoded value as input. If you use a function that takes text as input, the result is a longer string which is invalid for the purposes of UID2.
67+
:::
68+
6169
| Type | Example | Comments and Usage |
6270
| :--- | :--- | :--- |
6371
| Raw email address | `[email protected]` | N/A |
6472
| Normalized email address | `[email protected]` | Normalization is always the first step. |
6573
| SHA-256 hash of normalized email address | `b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514` | This 64-character string is a hex-encoded representation of the 32-byte SHA-256. |
6674
| Hex to Base64 encoding of SHA-256 hash | `tMmiiTI7IaAcPpQPFQ65uMVCWH8av9jw4cwf/F5HVRQ=` | This 44-character string is a Base64-encoded representation of the 32-byte SHA-256.<br/>WARNING: The SHA-256 hash string in the example above is a hex-encoded representation of the hash value. You must Base64-encode the raw bytes of the hash or use a Base64 encoder that takes a hex-encoded value as input.<br/>Use this encoding for `email_hash` values sent in the request body. |
6775

68-
:::important
69-
When applying Base64 encoding, be sure to Base64-encode the raw bytes of the hash or use a Base64 encoder that takes a hex-encoded value as input.
70-
:::
71-
7276
For additional examples, see [Normalization Examples for Email](#normalization-examples-for-email).
7377

7478
## Normalization Examples for Email
@@ -77,14 +81,65 @@ The following table shows examples of original email addresses and the normalize
7781

7882
Some of the examples show email addresses that include the plus sign (+), with different domains. For `gmail` addresses, the plus sign and following characters, up to the `@` sign, are ignored in normalization. For other domains, these characters are included in the normalized value.
7983

80-
| Original Value | Normalized | Hashed and Base64-Encoded |
84+
:::important
85+
In working with your own UID2s, always provide the final value, the Base64-encoded value, to the UID2 Operator endpoint.
86+
:::
87+
88+
<table>
89+
<thead>
90+
<tr>
91+
<th>Original Value</th>
92+
<th>Processing Steps</th>
93+
<th>Resulting Values</th>
94+
</tr>
95+
</thead>
96+
<tbody>
97+
<tr>
98+
99+
<td>1. Normalize<br/>2. Hash<br/>3. Base64-Encode</td>
100+
<td>`[email protected]`<br/>`16c18d336f0b250f0e2d907452ceb9658a74ecdae8bc94864c23122a72cc27a5`<br/>`FsGNM28LJQ8OLZB0Us65ZYp07NrovJSGTCMSKnLMJ6U=`</td>
101+
</tr>
102+
<tr>
103+
104+
<td>1. Normalize<br/>2. Hash<br/>3. Base64-Encode</td>
105+
<td>`[email protected]`<br/>`16c18d336f0b250f0e2d907452ceb9658a74ecdae8bc94864c23122a72cc27a5`<br/>`FsGNM28LJQ8OLZB0Us65ZYp07NrovJSGTCMSKnLMJ6U=`</td>
106+
</tr>
107+
<tr>
108+
<td>`[email protected]`</td>
109+
<td>1. Normalize<br/>2. Hash<br/>3. Base64-Encode</td>
110+
<td>`[email protected]`<br/>`e22b53bc6f871274f3a62ab37a3caed7214fc14d676215a96a242fcfada1c81f`<br/>`4itTvG+HEnTzpiqzejyu1yFPwU1nYhWpaiQvz62hyB8=`</td>
111+
</tr>
112+
<tr>
113+
114+
<td>1. Normalize<br/>2. Hash<br/>3. Base64-Encode</td>
115+
<td>`[email protected]`<br/>`d6670e7a92007f1b5ff785f1fc81e53aa6d3d7bd06bdf5c473cdc7286c284b6d`<br/>`1mcOepIAfxtf94Xx/IHlOqbT170GvfXEc83HKGwoS20=`</td>
116+
</tr>
117+
<tr>
118+
119+
<td>1. Normalize<br/>2. Hash<br/>3. Base64-Encode</td>
120+
<td>`[email protected]`<br/>`b196432c7b989a2ca91c83799957c515da53e6c13abf20b78fea94f117e90bf8`<br/>`sZZDLHuYmiypHIN5mVfFFdpT5sE6vyC3j+qU8RfpC/g=`</td>
121+
</tr>
122+
<tr>
123+
<td>`[email protected]`</td>
124+
<td>1. Normalize<br/>2. Hash<br/>3. Base64-Encode</td>
125+
<td>`[email protected]`<br/>`28aaee4815230cd3b4ebd88c515226550666e91ac019929e3adac3f66c288180`<br/>`KKruSBUjDNO069iMUVImVQZm6RrAGZKeOtrD9mwogYA=`</td>
126+
</tr>
127+
<tr>
128+
129+
<td>1. Normalize<br/>2. Hash<br/>3. Base64-Encode</td>
130+
<td>`[email protected]`<br/>`92ee26057ed9dea2535d6c8b141d48373932476599196e00352254896db5888f`<br/>`ku4mBX7Z3qJTXWyLFB1INzkyR2WZGW4ANSJUiW21iI8=`</td>
131+
</tr>
132+
</tbody>
133+
</table>
134+
135+
<!-- | Original Value | Normalized | Hashed and Base64-Encoded |
81136
| :--- | :--- | :--- |
82137
| `[email protected]`<br/>`[email protected]` | `[email protected]` | Hashed: `16c18d336f0b250f0e2d907452ceb9658a74ecdae8bc94864c23122a72cc27a5`<br/>Base64-Encoded: `FsGNM28LJQ8OLZB0Us65ZYp07NrovJSGTCMSKnLMJ6U=` |
83138
| `[email protected]` | `[email protected]` | Hashed: `e22b53bc6f871274f3a62ab37a3caed7214fc14d676215a96a242fcfada1c81f`<br/>Base64-Encoded: `4itTvG+HEnTzpiqzejyu1yFPwU1nYhWpaiQvz62hyB8=` |
84139
| `[email protected]`<br/>`[email protected]` | `[email protected]` | Hashed: `d6670e7a92007f1b5ff785f1fc81e53aa6d3d7bd06bdf5c473cdc7286c284b6d`<br/>Base64-Encoded: `1mcOepIAfxtf94Xx/IHlOqbT170GvfXEc83HKGwoS20=` |
85140
| `[email protected]`<br/>`[email protected]` | `[email protected]` | Hashed: ` b196432c7b989a2ca91c83799957c515da53e6c13abf20b78fea94f117e90bf8`<br/>Base64-Encoded: `sZZDLHuYmiypHIN5mVfFFdpT5sE6vyC3j+qU8RfpC/g=` |
86141
| `[email protected]` | `[email protected]` | Hashed: `28aaee4815230cd3b4ebd88c515226550666e91ac019929e3adac3f66c288180`<br/>Base64-Encoded: `KKruSBUjDNO069iMUVImVQZm6RrAGZKeOtrD9mwogYA=` |
87-
| `[email protected]`<br/>`[email protected]`<br/>`[email protected]` | `[email protected]` | Hashed: `92ee26057ed9dea2535d6c8b141d48373932476599196e00352254896db5888f`<br/>Base64-Encoded: `ku4mBX7Z3qJTXWyLFB1INzkyR2WZGW4ANSJUiW21iI8=` |
142+
| `[email protected]`<br/>`[email protected]`<br/>`[email protected]` | `[email protected]` | Hashed: `92ee26057ed9dea2535d6c8b141d48373932476599196e00352254896db5888f`<br/>Base64-Encoded: `ku4mBX7Z3qJTXWyLFB1INzkyR2WZGW4ANSJUiW21iI8=` | -->
88143

89144
## Phone Number Normalization
90145

@@ -113,17 +168,19 @@ A phone number hash is a Base64-encoded SHA-256 hash of a normalized phone numbe
113168

114169
The following table shows an example of a simple input phone number, and the result as each step is applied to arrive at a secure, opaque, URL-safe value.
115170

171+
The final value, the hex to Base64 encoded representation of the SHA-256 hash, is the value to provide to the UID2 Operator endpoint.
172+
173+
:::warning
174+
When applying Base64 encoding, be sure to use a function that takes a hex value as input. If you use a function that takes text as input, the result is a longer string which is invalid for the purposes of UID2.
175+
:::
176+
116177
| Type | Example | Comments and Usage |
117178
| :--- | :--- | :--- |
118179
| Raw phone number | `1 (234) 567-8901` | N/A |
119180
| Normalized phone number | `+12345678901` | Normalization is always the first step. |
120181
| SHA-256 hash of normalized phone number | `10e6f0b47054a83359477dcb35231db6de5c69fb1816e1a6b98e192de9e5b9ee` |This 64-character string is a hex-encoded representation of the 32-byte SHA-256. |
121182
| Hex to Base64 encoding of SHA-256 hash | `EObwtHBUqDNZR33LNSMdtt5cafsYFuGmuY4ZLenlue4=` | This 44-character string is a Base64-encoded representation of the 32-byte SHA-256.<br/>NOTE: The SHA-256 hash is a hexadecimal value. You must use a Base64 encoder that takes a hex value as input. Use this encoding for `phone_hash` values sent in the request body. |
122183

123-
:::warning
124-
When applying Base64 encoding, be sure to use a function that takes a hex value as input. If you use a function that takes text as input, the result is a longer string which is invalid for the purposes of UID2.
125-
:::
126-
127184
## Example Code
128185

129186
For an example of how to generate email and phone hashes in JavaScript, see [Example Code: Hashing and Base-64 Encoding](../guides/integration-javascript-client-side#example-code-hashing-and-base-64-encoding).
@@ -151,3 +208,21 @@ The tool does the following:
151208
If the input data doesn't have a valid email or phone number format, or if the phone number is not normalized, the tool gives an error.
152209

153210
You can use this tool to verify that your internal processes are set up to correctly create normalized, hashed, and encoded values for UID2.
211+
212+
## Troubleshooting
213+
214+
If you're having trouble or getting errors, or even if you just want to be sure you're following the steps correctly, here are some things you can check:
215+
216+
- **Hashing tool**: In all scenarios, follow the steps on your side, and then check by using the [UID2 Hashing Tool](#uid2-hashing-tool). If the results don't match, check each step to find the error.
217+
218+
- **Phone numbers**: Make sure you're normalizing&#8212;and normalizing correctly&#8212;as the first step.
219+
220+
If you're processing emails, the service does the normalization; however, with phone numbers, the service cannot normalize. For example, it cannot determine a missing country code. Use these resources:
221+
- For instructions, see [Phone Number Normalization](#phone-number-normalization).
222+
- To cross-check, test using the [UID2 Hashing Tool](#uid2-hashing-tool).
223+
224+
- **Use the Base64-encoded value**: The process includes normalizing, then hashing, then Base64-encoding the bytes of the hash value. When generating UID2s, the input is the Base64-encoded value. Make sure you're using this 44-character string value.
225+
226+
- You might see the following error message: "The hashing value must be 44 characters." In this scenario, there is an error with the hashing function you are using. You must use the hex to Base64 encoding of the SHA-256 hash. For details, see [Email Address Hash Encoding](#email-address-hash-encoding) or [Phone Number Hash Encoding](#phone-number-hash-encoding).
227+
228+
To cross-check, test using the [UID2 Hashing Tool](#uid2-hashing-tool).

docs/guides/integration-javascript-client-side.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ To configure the SDK, call one of the following methods, with an object containi
175175
* `__uid2.setIdentityFromPhone`
176176
* `__uid2.setIdentityFromPhoneHash`
177177

178+
:::important
179+
For `__uid2.setIdentityFromEmailHash` or `__uid2.setIdentityFromPhoneHash`, the `emailHash` or `PhoneHash` argument must be the Base64-encoded value. For details, see [Email Address Hash Encoding](../getting-started/gs-normalization-encoding.md/#email-address-hash-encoding) and [Phone Number Hash Encoding](../getting-started/gs-normalization-encoding.md#phone-number-hash-encoding).
180+
:::
181+
178182
The following sections include coding examples for each scenario.
179183

180184
Once it's configured, the UID2 SDK takes care of the following:

0 commit comments

Comments
 (0)