mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
Create generate_condition.py
This commit is contained in:
19
content/_code-samples/escrow/py/generate_condition.py
Normal file
19
content/_code-samples/escrow/py/generate_condition.py
Normal file
@@ -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}")
|
||||||
Reference in New Issue
Block a user