You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
471 B
13 lines
471 B
1 year ago
|
import {createHash} from 'crypto';
|
||
|
|
||
|
/**
|
||
1 year ago
|
* Returns a hash of `id` prefixed with the first 4 characters of `id`. The first 4
|
||
|
* characters are included to assist with troubleshooting.
|
||
1 year ago
|
*
|
||
|
* Useful for situations where potentially sensitive identifiers are logged, such as
|
||
1 year ago
|
* doc ids of docs that have public link sharing enabled.
|
||
1 year ago
|
*/
|
||
|
export function hashId(id: string): string {
|
||
|
return `${id.slice(0, 4)}:${createHash('sha256').update(id.slice(4)).digest('base64')}`;
|
||
|
}
|