Skip to content

The open alternative to Salesforce, designed for AI.

538 B
Raw Blame
export const getLinkedinPersonId = async (slug: string): Promise<string> => {
  const digest = new Uint8Array(
    await crypto.subtle.digest(
      'SHA-256',
      new TextEncoder().encode(`linkedin-person:${slug}`),
    ),
  ).slice(0, 16);

  digest[6] = (digest[6] & 0x0f) | 0x40;
  digest[8] = (digest[8] & 0x3f) | 0x80;

  const hex = [...digest]
    .map((byte) => byte.toString(16).padStart(2, '0'))
    .join('');

  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
};