Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Limited key size to 256 bytes, changed default key size to 16
Browse files Browse the repository at this point in the history
256 bytes is still ridiculous but it's more realistic than 64K.
  • Loading branch information
TypicalHog committed Jul 13, 2017
1 parent 5af4c6b commit 520da01
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ C++ console application that features symmetric key based file encryption.
### Some facts
-It is possible to encrypt the file with another file.

-Key can be up to 65536 characters long. (16 is more than enough though :O)
-Key can be up to 256 characters long. (16 is more than enough though :O)

-Time complexity is linear, but every new character added to the key makes the brute-force attack 2^8 times harder.

Expand Down
1 change: 0 additions & 1 deletion ROADMAP.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Important
-Detect if file already exists and prompt user for action
-Continue progress on canceled operation
-Option to delete original file and/or key file (with both normal and secure deletion)
-Increase key size beyond 65536 characters limit (or even limit it to 256)
-Encrypt the original file directly (without making a copy)
-Preallocate files

Expand Down
12 changes: 6 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// THCrypt v1.2
// THCrypt v1.3
// Copyright (c) 2017 TypicalHog
// https://github.com/TypicalHog/THCrypt

Expand Down Expand Up @@ -57,7 +57,7 @@ int main(int argc, char *argv[])
}

filename_key = "key.txt";
const int new_key_size = 32;
const int new_key_size = 16;
switch (generate_key(filename_key, new_key_size))
{
case 0:
Expand Down Expand Up @@ -129,7 +129,7 @@ int main(int argc, char *argv[])

if (f_in.is_open() && f_out.is_open() && f_key.is_open() && f_lookup_table.is_open())
{
unsigned char key[256 * 256];
unsigned char key[256];
unsigned char p_buffer[256 * 256];
unsigned char s_buffer[256 * 256];
unsigned char lookup_table[256 * 256];
Expand All @@ -156,10 +156,10 @@ int main(int argc, char *argv[])
f_in.seekg(0, std::ios::beg);
num_chunks = (unsigned long long)ceil((double)file_size / (double)buffer_size);

if (key_size > 65536LL)
if (key_size > 256LL)
{
std::cout << "WARNING: Key too long, truncating to 65536 bytes!" << std::endl;
key_size = 65536LL;
std::cout << "WARNING: Key too long, truncating to 256 bytes!" << std::endl;
key_size = 256LL;
}
f_key.read(reinterpret_cast<char *>(&key), key_size);

Expand Down

0 comments on commit 520da01

Please sign in to comment.