Add examples for encrypt decrypt data
This commit is contained in:
parent
081a4fe05f
commit
21fcf5f274
|
@ -456,7 +456,7 @@ Execute `stop_clock` for stop timer.
|
||||||
Get digest
|
Get digest
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: python
|
||||||
|
|
||||||
data = 'LibreOffice with Python'
|
data = 'LibreOffice with Python'
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ Save and get configurations
|
||||||
|
|
||||||
You can save any data.
|
You can save any data.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: python
|
||||||
|
|
||||||
my_app = 'my_extension'
|
my_app = 'my_extension'
|
||||||
data = {
|
data = {
|
||||||
|
@ -489,5 +489,47 @@ You can save any data.
|
||||||
app.msgbox(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
|
.. _epoch time: https://en.wikipedia.org/wiki/Unix_time
|
||||||
|
.. _cryptography: https://github.com/pyca/cryptography
|
||||||
|
|
Loading…
Reference in New Issue