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