From bf3eb9390415caa149a4db6fe121092e36fbb0d5 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Sat, 3 Sep 2022 00:47:23 -0700 Subject: [PATCH] Create generate_condition.py --- .../escrow/py/generate_condition.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 content/_code-samples/escrow/py/generate_condition.py diff --git a/content/_code-samples/escrow/py/generate_condition.py b/content/_code-samples/escrow/py/generate_condition.py new file mode 100644 index 0000000000..35c6079c23 --- /dev/null +++ b/content/_code-samples/escrow/py/generate_condition.py @@ -0,0 +1,19 @@ +import random +from os import urandom + +from cryptoconditions import PreimageSha256 + +# """Generate a condition and fulfillment for escrows""" + +# whatever you please +secret = urandom(random.randint(32, 64)) + +# generate cryptic image from secret +fufill = PreimageSha256(preimage=secret) + +# parse image and return the condition and fulfillment +condition = str.upper(fufill.condition_binary.hex()) # conditon +fulfillment = str.upper(fufill.serialize_binary().hex()) # fulfillment + +# print condition and fulfillment +print(f"condition: {condition} \n fulfillment {fulfillment}")