Add examples for encrypt decrypt data

This commit is contained in:
Mauricio Baeza 2021-06-22 22:32:49 -05:00
parent 081a4fe05f
commit 21fcf5f274
1 changed files with 44 additions and 2 deletions

View File

@ -456,7 +456,7 @@ Execute `stop_clock` for stop timer.
Get digest
^^^^^^^^^^
.. code-block:: bash
.. code-block:: python
data = 'LibreOffice with Python'
@ -472,7 +472,7 @@ Save and get configurations
You can save any data.
.. code-block:: bash
.. code-block:: python
my_app = 'my_extension'
data = {
@ -489,5 +489,47 @@ You can save any data.
app.msgbox(data)
Render string
^^^^^^^^^^^^^
.. code-block:: python
template = """Hello $name
I send you this $file_name
Best regards
"""
data = {'name': 'Ingrid Bergman', 'file_name': 'letter_love.odt'}
render = app.render(template, data)
app.msgbox(render)
Encrypt decrypt
^^^^^^^^^^^^^^^
You need install library `cryptography`_
.. code-block:: python
import easymacro as app
from conf import PASSWORD
def encrypt_decrypt():
data = 'My super secret data'
token = app.encrypt(data, PASSWORD)
app.msgbox(token)
data = app.decrypt(token, PASSWORD)
app.msgbox(data)
return
.. _epoch time: https://en.wikipedia.org/wiki/Unix_time
.. _cryptography: https://github.com/pyca/cryptography