Hack Forums
[Python] Encrypt and decrypt txt file - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Encrypt and decrypt txt file (/showthread.php?tid=5783081)



Encrypt and decrypt txt file - iboyhacker_1997 - Jan 11, 2018

How can i do Encrypt and decrypt txt file With Python programming ?


RE: Encrypt and decrypt txt file - HFDone - Jan 11, 2018

depends on what you need it for.
you can just encode it to base64 or you can use https://pypi.python.org/pypi/pycrypto/2.6.1


RE: Encrypt and decrypt txt file - Payload - Jan 11, 2018

(Jan 11, 2018 05:15 AM)HFDone Wrote:  depends on what you need it for.
you can just encode it to base64 or you can use https://pypi.python.org/pypi/pycrypto/2.6.1

Base64 is encoding, not encryption.


RE: Encrypt and decrypt txt file - HFDone - Jan 11, 2018

(Jan 11, 2018 05:16 AM)Payload Wrote:  Base64 is encoding, not encryption.

try to read it again and you should see why your reply is stupid  ❓


RE: Encrypt and decrypt txt file - iboyhacker_1997 - Jan 11, 2018

I want for txt file !!!!!!!!!!!!!!!


RE: Encrypt and decrypt txt file - TheMarkMan - Jan 11, 2018

(Jan 11, 2018 10:15 AM)iboyhacker_1997 Wrote:  I want for txt file !!!!!!!!!!!!!!!

There have been suggestions on how to encrypt a text file. If you want someone to write code for you, then ask. You’ve been suggested to use a module for encryption by another user, albeit for outdated python 2.6.

Here is documentation showing how to use the module PyCryptodome (works for Python 3.1) to encrypt text.
https://www.pycryptodome.org/en/latest/src/examples.html#encrypt-data-with-aes

Heres a quick algorithm to help you out.

1. Read the text from the file into a variable
2. Run the string through an encryption module
3. Overwrite the original text file data with the encrypted string variable


RE: Encrypt and decrypt txt file - HFDone - Jan 11, 2018

(Jan 11, 2018 05:16 AM)Payload Wrote:  Base64 is encoding, not encryption.

kid learn to read you think i care about rep  🤣 i will report you for fake rep  😉 im here from 2010 and knows about coding much more then you and the others kids here.
Edit - report you for lying


RE: Encrypt and decrypt txt file - Itsumi - Jan 11, 2018

If you want some code, (rather than arguments), here you go:

Code
def encrypt(par1):
    #run some sort of encryption here and return it

file_to_encrypt = open("test.txt", "wb")
file_to_encrypt.write(bytes(encrypt(file_to_encrypt.read()), 'UTF-8'))

Something like that.