![]() |
|
Encrypting a file line by line - نسخة قابلة للطباعة +- Forums (http://ftth.kozow.com) +-- المنتدى: قسم الشرينج والـ IP (http://ftth.kozow.com/forumdisplay.php?fid=5) +--- المنتدى: شروحات و مشاكل الـ VPS و LINUX (http://ftth.kozow.com/forumdisplay.php?fid=7) +--- الموضوع: Encrypting a file line by line (/showthread.php?tid=10) |
Encrypting a file line by line - ftth - 11-04-2025 Encrypting a file line by line
You can use a Bash loop to process the file line by line. This example uses
How to run the script:
bash
كود: ./Encryptinglinebyline.sh /path/to/input_file.txtbash
كود: #!/bin/bashDecrypting the file line by line
The decryption process also involves reading each line of the encrypted file and decrypting it individually.
bash
كود: #!/bin/bashAlternative: Encrypting the entire file at once
For most standard use cases, it is much simpler and more efficient to encrypt the entire file using a single OpenSSL command:
[b]Encryption:[/b]
bash
كود: openssl enc -aes-256-cbc -salt -pbkdf2 -a -e -in plaintext.txt -out encrypted.txt[b]Decryption:[/b]
bash
كود: openssl enc -d -aes-256-cbc -salt -pbkdf2 -a -in encrypted.txt -out decrypted.txt |