Buckets:
MisterAI/LocalAI_Demo_backends / cpu-diffusers /venv /lib /python3.10 /site-packages /zmq /curve_keygen.py
| """ | |
| Generate a zmq curve keypair. | |
| Generates a 'public' and a 'secret' key. | |
| Add `--json` to output as a JSON dictionary. | |
| Add `--secret SECRET` to derive public key from an existing secret key. | |
| CURVE keys are always z85-encoded (ASCII safe). | |
| """ | |
| import argparse | |
| import json | |
| import sys | |
| import zmq | |
| def _main() -> None: | |
| parser = argparse.ArgumentParser( | |
| prog="python3 -m zmq.curve_keygen", | |
| description=__doc__, | |
| ) | |
| parser.add_argument("--json", action="store_true", help="output keys as JSON dict") | |
| parser.add_argument( | |
| "--secret", type=str, help="specify secret key to derive a public key" | |
| ) | |
| opts = parser.parse_args() | |
| if opts.secret: | |
| secret = opts.secret | |
| public = zmq.curve_public(secret.encode()).decode() | |
| else: | |
| public_b, secret_b = zmq.curve_keypair() | |
| public = public_b.decode() | |
| secret = secret_b.decode() | |
| if opts.json: | |
| json.dump( | |
| { | |
| "public": public, | |
| "secret": secret, | |
| }, | |
| sys.stdout, | |
| indent=1, | |
| sort_keys=True, | |
| ) | |
| sys.stdout.write("\n") | |
| else: | |
| # stdout, match libzmq curve_keygen format | |
| # without the big disclaimer | |
| print("== CURVE PUBLIC KEY ==") | |
| print(public) | |
| print() | |
| print("== CURVE SECRET KEY ==") | |
| print(secret) | |
| if __name__ == "__main__": | |
| _main() | |
Xet Storage Details
- Size:
- 1.43 kB
- Xet hash:
- 8ee122259a2f32ded605692394a33790586689a8d1cd4961b185316f6ca1c211
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.