Protect PII using a Hash Key
mainCopycat uses SipHash to map inputs to outputs, making it computationally infeasible to infer the original input from the output. However, an attacker with access to the Copycat library can perform a brute-force attack by guessing inputs until they find a match.
To prevent this, use a secret key with copycat.generateHashKey and apply it via copycat.setHashKey. This ensures that even if the library code is public, the mapping remains unknown to attackers without the key.
// 1. Generate a key from a secret string and store it safely
const key = copycat.generateHashKey('g9u*rT#!72R$zl5e')
// 2. Apply the key to Copycat
copycat.setHashKey(key)
// Now mappings are unique to this key
copycat.fullName('foo') // => 'Bertha Sauer'