I am crating a program in java that reads an Input Stream of a file, encrypts it by changing around the numbers of the bytes based on what the password is, and creates a new encrypted file.
For example:
I created a test file that contained the words:This is a test to see if the encrypter project works.
When I read the bytes in java, I get:[84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 116, 101, 115, 116, 32, 116, 111, 32, 115, 101, 101, 32, 105, 102, 32, 116, 104, 101, 32, 101, 110, 99, 114, 121, 112, 116, 101, 114, 32, 112, 114, 111, 106, 101, 99, 116, 32, 119, 111, 114, 107, 115, 46, 10]
So then I take the value of each byte, and subtract the unicode value of the passwords, and get the absolute value of that. Then I write that to a file.
I was playing around with different algorithms to encrypt it, and started testing it out on a test text file. I am using Linux, so so there are no file extensions (eg. .txt, .pdf, etc...) I noticed after a few times of encrypting it, that the computer no longer recognized it as a text file, but instead, as an image file! (meaning when you click on it, by default, it tries to open the file in an image editor)
So here are my questions:
.pdf
extension, or is it because of the bytes that are somewhere in the file.)To find out file types we can use the file command. Using the -s option we can read the block or character special file. Using -F option will use string as separator instead of “:”. We can use the –extension option to print a slash-separated list of valid extensions for the file type found.
Change File Extensions From the Terminal And if you want to change the extension (or the name), you'd use the mv command. mv stands for "move" and is the standard command on Linux for moving and renaming files.
The file command uses the /etc/magic file to identify files that have a magic number; that is, any file containing a numeric or string constant that indicates the type. This displays the file type of myfile (such as directory, data, ASCII text, C program source, or archive).
file determines the format of each file by inspecting the attributes and (for a regular file) reading the contents of the file. If the file is an executable, its addressing mode is determined for output.
On traditional UNIX systems, files are identified solely by looking for particular patterns of bytes appearing in the file.
The file
command uses a magic
configuration file (often /etc/magic
, or /usr/share/file/magic
) which contains the rules defining those byte patterns.
That's it - there's no special extra meta-data - it's all done by analysis of the content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With