So I have a long text file and the Decryption function only reads in 3 lines and I have no idea why.
The Decrypt and the Encrypt converts ints to unsigned char and returns it.
The Encryption encrypts 1 char and adds the step to the key
Thank you to anyone who has an idea what can be the problem
check the basics.
what is in the file you opened? Did it encrypt all the lines into it correctly (stop after encrypt and exit, open encrypted file in text or hex editor to see if it is right)? Did you close or flush it after writing it (an open file may not be fully written to disk, you can flush or close it before reopen to avoid issues)?
xor encryption/decryption (result file is binary, not text, though, is the only aggravation to it) can be done in about 10 lines of code. These exotic newspaper puzzle page algorithms are just too much aggravation, to be honest. That algorithm is
- get file size
- read entire file to a buffer
- set up <random> using (int) of user's password (hashed somehow to get int) as seed
- xor each byte with random
- write file
- self reverses, just re-run with same password to decrypt.
Thank you for the comment but I close the files and I took a look at the ascii and where it stops reading its only the end line code 0D 0A (because im using Windows for this program). I wrote in the clears but didnt help a bit.
This is how I make the file: