@@ -69,6 +69,30 @@ def encrypt(
69
69
provider_options : dict | None = None ,
70
70
** encryption_context : str ,
71
71
) -> str :
72
+ """
73
+ Encrypt data using the configured encryption provider.
74
+
75
+ Parameters
76
+ ----------
77
+ data : dict, Mapping, Sequence, or Number
78
+ The data to encrypt.
79
+ provider_options : dict, optional
80
+ Provider-specific options for encryption.
81
+ **encryption_context : str
82
+ Additional key-value pairs for encryption context.
83
+
84
+ Returns
85
+ -------
86
+ str
87
+ The encrypted data as a base64-encoded string.
88
+
89
+ Example
90
+ --------
91
+
92
+ encryption_provider = AWSEncryptionSDKProvider(keys=[KMS_KEY_ARN])
93
+ data_masker = DataMasking(provider=encryption_provider)
94
+ encrypted = data_masker.encrypt({"secret": "value"})
95
+ """
72
96
return self ._apply_action (
73
97
data = data ,
74
98
fields = None ,
@@ -87,6 +111,31 @@ def decrypt(
87
111
provider_options : dict | None = None ,
88
112
** encryption_context : str ,
89
113
) -> Any :
114
+ """
115
+ Decrypt data using the configured encryption provider.
116
+
117
+ Parameters
118
+ ----------
119
+ data : dict, Mapping, Sequence, or Number
120
+ The data to encrypt.
121
+ provider_options : dict, optional
122
+ Provider-specific options for encryption.
123
+ **encryption_context : str
124
+ Additional key-value pairs for encryption context.
125
+
126
+ Returns
127
+ -------
128
+ str
129
+ The encrypted data as a base64-encoded string.
130
+
131
+ Example
132
+ --------
133
+
134
+ encryption_provider = AWSEncryptionSDKProvider(keys=[KMS_KEY_ARN])
135
+ data_masker = DataMasking(provider=encryption_provider)
136
+ encrypted = data_masker.decrypt(encrypted_data)
137
+ """
138
+
90
139
return self ._apply_action (
91
140
data = data ,
92
141
fields = None ,
@@ -110,6 +159,31 @@ def erase(
110
159
mask_format : str | None = None ,
111
160
masking_rules : dict | None = None ,
112
161
) -> Any :
162
+ """
163
+ Erase or mask sensitive data in the input.
164
+
165
+ Parameters
166
+ ----------
167
+ data : Any
168
+ The data to be erased or masked.
169
+ fields : list of str, optional
170
+ List of field names to be erased or masked.
171
+ dynamic_mask : bool, optional
172
+ Whether to use dynamic masking.
173
+ custom_mask : str, optional
174
+ Custom mask to apply instead of the default.
175
+ regex_pattern : str, optional
176
+ Regular expression pattern for identifying data to mask.
177
+ mask_format : str, optional
178
+ Format string for the mask.
179
+ masking_rules : dict, optional
180
+ Dictionary of custom masking rules.
181
+
182
+ Returns
183
+ -------
184
+ Any
185
+ The data with sensitive information erased or masked.
186
+ """
113
187
if masking_rules :
114
188
return self ._apply_masking_rules (data = data , masking_rules = masking_rules )
115
189
else :
@@ -313,7 +387,11 @@ def _apply_masking_rules(self, data: dict, masking_rules: dict) -> dict:
313
387
match .full_path .update (result , masked_value )
314
388
315
389
except Exception as e :
316
- warnings .warn (f"Error masking value for path { path } : { str (e )} " , category = PowertoolsUserWarning , stacklevel = 2 )
390
+ warnings .warn (
391
+ f"Error masking value for path { path } : { str (e )} " ,
392
+ category = PowertoolsUserWarning ,
393
+ stacklevel = 2 ,
394
+ )
317
395
continue
318
396
319
397
except Exception as e :
0 commit comments