summaryrefslogtreecommitdiff
path: root/Biz/Bild/Example.py
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Bild/Example.py')
-rw-r--r--Biz/Bild/Example.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Biz/Bild/Example.py b/Biz/Bild/Example.py
new file mode 100644
index 0000000..78a8a6a
--- /dev/null
+++ b/Biz/Bild/Example.py
@@ -0,0 +1,30 @@
+# : out example
+# : dep cryptography
+import sys
+from typing import List
+
+from cryptography.fernet import Fernet
+
+
+def cryptic_hello(name: str) -> str:
+ "Example taken from `cryptography` docs."
+ key = Fernet.generate_key()
+ f = Fernet(key)
+ token = f.encrypt(hello(name).encode("utf-8"))
+ ret = f.decrypt(token).decode("utf-8")
+ assert ret == hello(name)
+ return ret
+
+
+def hello(name: str) -> str:
+ return f"Hello {name}"
+
+
+def main() -> None:
+ if "test" in sys.argv:
+ print("testing success")
+ print(cryptic_hello("world"))
+
+
+if __name__ == "__main__":
+ main()