( projectId, string, alphabet, keyName, wrappedKey, surrogateType )
| 19 | // description: Re-identify text data with format-preserving encryption. |
| 20 | // usage: node reidentifyTextWithFpe.js my-project string alphabet surrogateType keyName wrappedKey |
| 21 | async function main( |
| 22 | projectId, |
| 23 | string, |
| 24 | alphabet, |
| 25 | keyName, |
| 26 | wrappedKey, |
| 27 | surrogateType |
| 28 | ) { |
| 29 | // [START dlp_reidentify_text_fpe] |
| 30 | // Imports the Google Cloud Data Loss Prevention library |
| 31 | const DLP = require('@google-cloud/dlp'); |
| 32 | |
| 33 | // Instantiates a client |
| 34 | const dlp = new DLP.DlpServiceClient(); |
| 35 | |
| 36 | // The project ID to run the API call under |
| 37 | // const projectId = 'my-project'; |
| 38 | |
| 39 | // The string to reidentify |
| 40 | // const string = 'My phone number is PHONE_TOKEN(10):9617256398'; |
| 41 | |
| 42 | // The set of characters to replace sensitive ones with |
| 43 | // For more information, see https://cloud.google.com/dlp/docs/reference/rest/v2/organizations.deidentifyTemplates#ffxcommonnativealphabet |
| 44 | // const alphabet = 'NUMERIC'; |
| 45 | |
| 46 | // The name of the Cloud KMS key used to encrypt ('wrap') the AES-256 key |
| 47 | // const keyName = 'projects/YOUR_GCLOUD_PROJECT/locations/YOUR_LOCATION/keyRings/YOUR_KEYRING_NAME/cryptoKeys/YOUR_KEY_NAME'; |
| 48 | |
| 49 | // The encrypted ('wrapped') AES-256 key to use |
| 50 | // This key should be encrypted using the Cloud KMS key specified above |
| 51 | // const wrappedKey = 'YOUR_ENCRYPTED_AES_256_KEY' |
| 52 | |
| 53 | // The name of the surrogate custom info type to use when reidentifying data |
| 54 | // const surrogateType = 'SOME_INFO_TYPE_DEID'; |
| 55 | |
| 56 | async function reidentifyTextWithFpe() { |
| 57 | // Construct deidentification request |
| 58 | const item = {value: string}; |
| 59 | |
| 60 | // Construt Crypto Key Configuration |
| 61 | const cryptoKeyConfig = { |
| 62 | kmsWrapped: { |
| 63 | wrappedKey: wrappedKey, |
| 64 | cryptoKeyName: keyName, |
| 65 | }, |
| 66 | }; |
| 67 | |
| 68 | // Construct primitive transformation configuration |
| 69 | const primitiveTransformation = { |
| 70 | cryptoReplaceFfxFpeConfig: { |
| 71 | cryptoKey: cryptoKeyConfig, |
| 72 | commonAlphabet: alphabet, |
| 73 | surrogateInfoType: { |
| 74 | name: surrogateType, |
| 75 | }, |
| 76 | }, |
| 77 | }; |
| 78 |
nothing calls this directly
no test coverage detected