Download decrypt.py from shangdatalab-ucsd/midred: direct link, hf CLI and curl.
- Browser
- Download file 567 Bytes
-
https://huggingface.co/datasets/shangdatalab-ucsd/midred/resolve/main/decrypt.py
- Command line
-
hf download hf://datasets/shangdatalab-ucsd/midred/decrypt.py
-
curl -L -o decrypt.py https://huggingface.co/datasets/shangdatalab-ucsd/midred/resolve/main/decrypt.py
567 Bytes
| ''' | |
| This script is used to decrypt the encrypted data files. | |
| ''' | |
| from cryptography.fernet import Fernet | |
| # Open the key | |
| with open('filekey.key', 'rb') as filekey: | |
| key = filekey.read() | |
| fernet = Fernet(key) | |
| splits = ['train', 'dev', 'test'] | |
| for split in splits: | |
| # Open the encrypted file | |
| with open(f'encrypted_{split}.json', 'rb') as file: | |
| encrypted = file.read() | |
| # Decrypting the file | |
| decrypted = fernet.decrypt(encrypted) | |
| # Write the decrypted file | |
| with open(f'decrypted_{split}.json', 'wb') as f: | |
| f.write(decrypted) | |