public sealed class CharacterMaskConfig : IMessage<CharacterMaskConfig>, IEquatable<CharacterMaskConfig>, IDeepCloneable<CharacterMaskConfig>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Data Loss Prevention v2 API class CharacterMaskConfig.
Partially mask a string by replacing a given number of characters with a
fixed character. Masking can start from the beginning or end of the string.
This can be used on data of any type (numbers, longs, and so on) and when
de-identifying structured data we'll attempt to preserve the original data's
type. (This allows you to take a long like 123 and modify it to a string like
**3.
public RepeatedField<CharsToIgnore> CharactersToIgnore { get; }
When masking a string, items in this list will be skipped when replacing
characters. For example, if the input string is 555-555-5555 and you
instruct Cloud DLP to skip - and mask 5 characters with *, Cloud DLP
returns ***-**5-5555.
Character to use to mask the sensitive values—for example, * for an
alphabetic string such as a name, or 0 for a numeric string such as ZIP
code or credit card number. This string must have a length of 1. If not
supplied, this value defaults to * for strings, and 0 for digits.
Number of characters to mask. If not set, all matching chars will be
masked. Skipped characters do not count towards this tally.
If number_to_mask is negative, this denotes inverse masking. Cloud DLP
masks all but a number of characters.
For example, suppose you have the following values:
masking_character is *
number_to_mask is -4
reverse_order is false
CharsToIgnore includes -
Input string is 1234-5678-9012-3456
The resulting de-identified string is
****-****-****-3456. Cloud DLP masks all but the last four characters.
If reverse_order is true, all but the first four characters are masked
as 1234-****-****-****.
Mask characters in reverse order. For example, if masking_character is
0, number_to_mask is 14, and reverse_order is false, then the
input string 1234-5678-9012-3456 is masked as 00000000000000-3456.
If masking_character is *, number_to_mask is 3, and reverse_order
is true, then the string 12345 is masked as 12***.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eCharacterMaskConfig\u003c/code\u003e class in the Google Cloud Data Loss Prevention v2 API is 4.16.0, with numerous previous versions available for reference.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCharacterMaskConfig\u003c/code\u003e is used to partially mask strings by replacing characters with a specified masking character, allowing for masking from the beginning or end of the string.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify a list of characters to ignore during the masking process, and choose whether to mask a set number of characters or all of them.\u003c/p\u003e\n"],["\u003cp\u003eThe masking process can be reversed, masking all but a specified number of characters, and the order of the masking (forward or reverse) can be chosen.\u003c/p\u003e\n"],["\u003cp\u003eThis class is designed to be used on various data types, and to preserve the original data type of the data when de-identifying structured data.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Data Loss Prevention v2 API - Class CharacterMaskConfig (4.19.0)\n\nVersion latestkeyboard_arrow_down\n\n- [4.19.0 (latest)](/dotnet/docs/reference/Google.Cloud.Dlp.V2/latest/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.18.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.18.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.17.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.17.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.16.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.16.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.15.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.15.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.14.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.14.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.13.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.13.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.12.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.12.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.11.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.11.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.10.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.10.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.9.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.9.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.8.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.8.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.7.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.7.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.6.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.5.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.4.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.3.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.2.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.1.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/4.0.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/3.5.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/3.4.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/3.3.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/3.2.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [2.16.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/2.16.0/Google.Cloud.Dlp.V2.CharacterMaskConfig)\n- [2.15.0](/dotnet/docs/reference/Google.Cloud.Dlp.V2/2.15.0/Google.Cloud.Dlp.V2.CharacterMaskConfig) \n\n public sealed class CharacterMaskConfig : IMessage\u003cCharacterMaskConfig\u003e, IEquatable\u003cCharacterMaskConfig\u003e, IDeepCloneable\u003cCharacterMaskConfig\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Data Loss Prevention v2 API class CharacterMaskConfig.\n\nPartially mask a string by replacing a given number of characters with a\nfixed character. Masking can start from the beginning or end of the string.\nThis can be used on data of any type (numbers, longs, and so on) and when\nde-identifying structured data we'll attempt to preserve the original data's\ntype. (This allows you to take a long like 123 and modify it to a string like\n\\*\\*3. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e CharacterMaskConfig \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[CharacterMaskConfig](/dotnet/docs/reference/Google.Cloud.Dlp.V2/latest/Google.Cloud.Dlp.V2.CharacterMaskConfig), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[CharacterMaskConfig](/dotnet/docs/reference/Google.Cloud.Dlp.V2/latest/Google.Cloud.Dlp.V2.CharacterMaskConfig), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[CharacterMaskConfig](/dotnet/docs/reference/Google.Cloud.Dlp.V2/latest/Google.Cloud.Dlp.V2.CharacterMaskConfig), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Dlp.V2](/dotnet/docs/reference/Google.Cloud.Dlp.V2/latest/Google.Cloud.Dlp.V2)\n\nAssembly\n--------\n\nGoogle.Cloud.Dlp.V2.dll\n\nConstructors\n------------\n\n### CharacterMaskConfig()\n\n public CharacterMaskConfig()\n\n### CharacterMaskConfig(CharacterMaskConfig)\n\n public CharacterMaskConfig(CharacterMaskConfig other)\n\nProperties\n----------\n\n### CharactersToIgnore\n\n public RepeatedField\u003cCharsToIgnore\u003e CharactersToIgnore { get; }\n\nWhen masking a string, items in this list will be skipped when replacing\ncharacters. For example, if the input string is `555-555-5555` and you\ninstruct Cloud DLP to skip `-` and mask 5 characters with `*`, Cloud DLP\nreturns `***-**5-5555`.\n\n### MaskingCharacter\n\n public string MaskingCharacter { get; set; }\n\nCharacter to use to mask the sensitive values\\—for example, `*` for an\nalphabetic string such as a name, or `0` for a numeric string such as ZIP\ncode or credit card number. This string must have a length of 1. If not\nsupplied, this value defaults to `*` for strings, and `0` for digits.\n\n### NumberToMask\n\n public int NumberToMask { get; set; }\n\nNumber of characters to mask. If not set, all matching chars will be\nmasked. Skipped characters do not count towards this tally.\n\nIf `number_to_mask` is negative, this denotes inverse masking. Cloud DLP\nmasks all but a number of characters.\nFor example, suppose you have the following values:\n\n- `masking_character` is `*`\n- `number_to_mask` is `-4`\n- `reverse_order` is `false`\n- `CharsToIgnore` includes `-`\n- Input string is `1234-5678-9012-3456`\n\nThe resulting de-identified string is\n`****-****-****-3456`. Cloud DLP masks all but the last four characters.\nIf `reverse_order` is `true`, all but the first four characters are masked\nas `1234-****-****-****`.\n\n### ReverseOrder\n\n public bool ReverseOrder { get; set; }\n\nMask characters in reverse order. For example, if `masking_character` is\n`0`, `number_to_mask` is `14`, and `reverse_order` is `false`, then the\ninput string `1234-5678-9012-3456` is masked as `00000000000000-3456`.\nIf `masking_character` is `*`, `number_to_mask` is `3`, and `reverse_order`\nis `true`, then the string `12345` is masked as `12***`."]]