0
votes

I need to encrypt and decrypt a text file.For encryption and decryption i may use DES/AES algorithms.I have a code for encrypt and decrypt text file but the problem is,the first line in file must be encrypted in such a way it should be understandable.using AES and DES iam getting non readable format after encryption.I need to read the first line of file after encryption.Please help me .Thanks in advance

3
What do you mean when you say that the first line should be understandable after it is encrypted? Untouched, not encrypted? Or encypted in some way, but a way that seems friendly to the human eye? - DWright
encrypted in some way but it should be friendly to human eye - mounika

3 Answers

1
votes

Why not add a user-readable magic number to the beginning of the file, and again after you're done with the text block? Something like this:

MagiKrypt

This file has been encrypted with MagiKrypt, and you will need the program at (URL HERE) to decrypt it.

MakiKrypt\x00\x01\x02\x03
(AES data here)
EOF

This way your program would easily be able to tell where is text, and where is AES data, and the user would be able to read the first part of the file. It would still be a mess if they open it in a text editor, but at least they'd see the intro block.

0
votes

Encryption produces bytes, not human readable characters. To make your bytes human readable, you need to convert them to a different format. I would suggest Base64 as a common way to do this.

After you have encrypted your file, convert as much of it as you need to Base64 and display the Base64 part. It will not make any sense, but it won't contain anything too weird.

-1
votes

Its better to keep unecrypted the first line or you should cerate rules of your own and encrypt the first(and all) text.Its better to use SHAI algorithm for better encryptions.Other than SHA1 another choice is BTE encryption