MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

dlp/deIdentifyTableWithCryptoHash.js:21–112  ·  view source on GitHub ↗
(projectId, transientKeyName)

Source from the content-addressed store, hash-verified

19// description: Uses the Data Loss Prevention API to Deidentifying the table data with crypto key defined.
20// usage: node deIdentifyTableWithCryptoHash.js projectId, transientKeyName
21function main(projectId, transientKeyName) {
22 // [START dlp_deidentify_table_with_crypto_hash]
23 // Imports the Google Cloud Data Loss Prevention library
24 const DLP = require('@google-cloud/dlp');
25
26 // Instantiates a client
27 const dlp = new DLP.DlpServiceClient();
28
29 // The project ID to run the API call under
30 // const projectId = 'my-project';
31
32 // Crypto key
33 // const transientKeyName = 'YOUR_TRANSIENT_CRYPTO_KEY';
34
35 // The table to de-identify.
36 const tableToDeIdentify = {
37 headers: [{name: 'userid'}, {name: 'comments'}],
38 rows: [
39 {
40 values: [
41 {stringValue: 'user1@example.org'},
42 {
43 stringValue:
44 'my email is user1@example.org and phone is 858-555-0222',
45 },
46 ],
47 },
48 {
49 values: [
50 {stringValue: 'user2@example.org'},
51 {
52 stringValue:
53 'my email is user2@example.org and phone is 858-555-0223',
54 },
55 ],
56 },
57 {
58 values: [
59 {stringValue: 'user3@example.org'},
60 {
61 stringValue:
62 'my email is user3@example.org and phone is 858-555-0224',
63 },
64 ],
65 },
66 ],
67 };
68 async function deIdentifyTableWithCryptoHash() {
69 // Specify crypto hash configuration that uses transient key.
70 const cryptoHashConfig = {
71 cryptoKey: {
72 transient: {
73 name: transientKeyName,
74 },
75 },
76 };
77
78 // Construct de-identify request that uses crypto hash configuration.

Calls 1

Tested by

no test coverage detected