You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: daprdocs/content/en/python-sdk-docs/python-client.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -356,6 +356,40 @@ def main():
356
356
- Learn more about using a distributed lock: [How-To: Use a lock]({{< ref howto-use-distributed-lock.md >}}).
357
357
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/blob/master/examples/distributed_lock) for code samples and instructions to try out distributed lock.
358
358
359
+
### Cryptography
360
+
361
+
```python
362
+
from dapr.clients import DaprClient
363
+
364
+
message ='The secret is "passw0rd"'
365
+
366
+
defmain():
367
+
with DaprClient() as d:
368
+
resp = d.encrypt(
369
+
data=message.encode(),
370
+
options=EncryptOptions(
371
+
component_name='crypto-localstorage',
372
+
key_name='rsa-private-key.pem',
373
+
key_wrap_algorithm='RSA',
374
+
),
375
+
)
376
+
encrypt_bytes = resp.read()
377
+
378
+
resp = d.decrypt(
379
+
data=encrypt_bytes,
380
+
options=DecryptOptions(
381
+
component_name='crypto-localstorage',
382
+
key_name='rsa-private-key.pem',
383
+
),
384
+
)
385
+
decrypt_bytes = resp.read()
386
+
387
+
print(decrypt_bytes.decode()) # The secret is "passw0rd"
388
+
```
389
+
390
+
- For a full list of state operations visit [How-To: Use the cryptography APIs]({{< ref howto-cryptography.md >}}).
391
+
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/crypto) for code samples and instructions to try out cryptography
0 commit comments