Spaces:
Paused
Paused
Download generate_keys.py from YOSOYYONOSOYOTRO/crowdata: direct link, hf CLI and curl.
- Browser
- Download file 779 Bytes
-
https://huggingface.co/spaces/YOSOYYONOSOYOTRO/crowdata/resolve/main/generate_keys.py
- Command line
-
hf download hf://spaces/YOSOYYONOSOYOTRO/crowdata/generate_keys.py
-
curl -L -o generate_keys.py https://huggingface.co/spaces/YOSOYYONOSOYOTRO/crowdata/resolve/main/generate_keys.py
779 Bytes
| from cryptography.hazmat.primitives.asymmetric import rsa | |
| from cryptography.hazmat.primitives import serialization | |
| import os | |
| private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048) | |
| private_pem = private_key.private_bytes( | |
| encoding=serialization.Encoding.PEM, | |
| format=serialization.PrivateFormat.PKCS8, | |
| encryption_algorithm=serialization.NoEncryption() | |
| ) | |
| with open('private_key.pem', 'wb') as f: | |
| f.write(private_pem) | |
| public_key = private_key.public_key() | |
| public_pem = public_key.public_bytes( | |
| encoding=serialization.Encoding.PEM, | |
| format=serialization.PublicFormat.SubjectPublicKeyInfo | |
| ) | |
| with open('public_key.pem', 'wb') as f: | |
| f.write(public_pem) | |
| print('Keypair generado en E:/crowdata/backend/') | |
| print('Files:', os.listdir('.')) |