Skip to content

Commit 348651c

Browse files
committed
v1.7.0 patch
1 parent 0c793b1 commit 348651c

7 files changed

Lines changed: 19 additions & 23 deletions

File tree

Headers/Encryption/Compression/compressor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ namespace COMPRESSION {
121121
string str;
122122

123123
//First compression
124+
//Say you have 2 bytes 0100001100111100
125+
//That would be reduced to 010412021402
126+
//01 is the same, then 04 means repeat 0 four times in decompression, 12 = 11 etc....
124127
for (int i = 0, increment = 0; i < input.length(); i++) {
125128
for (increment = 1;; increment++) {
126129
if (input[i] != input[i+increment] || increment == 9) {break;};

Headers/Encryption/encryption.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ namespace encryption {
178178
int i = 0;
179179
//The first four of w [] are input keys
180180
while(i < AESwords_in_key) {
181-
w[i] = _4Bytes2Word(AESKEY::key[4*i], AESKEY::key[4*i+1], AESKEY::key[4*i+2], AESKEY::key[4*i+3]);
181+
w[i] = _4Bytes2Word(AES::KEY::key[4*i], AES::KEY::key[4*i+1], AES::KEY::key[4*i+2], AES::KEY::key[4*i+3]);
182182
++i;
183183
};
184184

@@ -343,7 +343,7 @@ namespace encryption {
343343
for (int i = 0; i < bitsInByte; i++) {
344344
bin[i] = getRandomNum(0, 1);
345345
};
346-
AESKEY::key[x] = bin;
346+
AES::KEY::key[x] = bin;
347347
};
348348
};
349349

@@ -355,7 +355,7 @@ namespace encryption {
355355
}
356356
else {
357357
for (int y = 0, n=0; y < mtx_size; y++, n+=bitsInByte) {
358-
AESKEY::key[y] = CONVERSIONS::binStr_to_byte(dummykey.substr(n, n+bitsInByte));
358+
AES::KEY::key[y] = CONVERSIONS::binStr_to_byte(dummykey.substr(n, n+bitsInByte));
359359
};
360360
};
361361
KeyExpansion(AES::global_expanded_key);
@@ -426,6 +426,7 @@ namespace encryption {
426426
/////////Pass through encrypt & decrypt functions//////
427427
/////////that input and output strings/////////////////
428428
///////////////////////////////////////////////////////
429+
AESbyte AES::KEY::key[mtx_size];
429430

430431
/////////////
431432
///Encrypt///

Headers/Encryption/encryption.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ constexpr unsigned short GLOBAL_MTX_SIZE = 4*4;
1212
namespace encryption {
1313

1414
namespace VERSION {
15-
static string ver = "v1.6.3";
15+
static string ver = "v1.6.4";
1616
//Major, Minor, Patch
1717
//for major or minor, change patch to 0
1818
}
@@ -23,12 +23,6 @@ namespace encryption {
2323
//This is THE key, made like this so you can just pre set the key and it's used throught the header seamlessly orbyou can prompt the user for a key and generate a key easily or anything with KEY::key
2424
static unsigned int key = DEFAULT_KEY_NUM;
2525
}
26-
namespace AESKEY {
27-
static AESbyte key[GLOBAL_MTX_SIZE] = {0x2b, 0x7e, 0x15, 0x16,
28-
0x28, 0xae, 0xd2, 0xa6,
29-
0xab, 0xf7, 0x15, 0x88,
30-
0x09, 0xcf, 0x4f, 0x3c};
31-
}
3226
class VIGENERE_KEY {
3327
public:
3428
static string key;
@@ -266,6 +260,10 @@ namespace encryption {
266260
};
267261

268262
public:
263+
class KEY {
264+
public:
265+
static AESbyte key[GLOBAL_MTX_SIZE];
266+
};
269267
enum OPTIONS {
270268
doGenerateKey = 0b00000000,
271269
noGenerateKey = 0b00000001,

ReadMe.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
## Thank you for using my header!
22

3-
### v1.6.3
3+
### v1.7.0
44

55
### What's new?
6-
###### v1.6.0
7-
Added binary compression to `encryptFile()`. So when `encrypt()` outputs a binary string, it gets encrypted using lossless compression. It has a ratio of about 3:1 on the bee movie script which is what I use to test large files.
8-
9-
###### v1.6.3
10-
Compression is now on all AES outputs
11-
12-
Removed bloat.
6+
Patched the AES key as the generated key was not being set to the key. Location has changed to `AES::KEY::key`. If you were using the previous version, `AESKEY::key` simply add `::` between `AES` and `KEY`.
137

148
## Basic Encryption
159
The program has the key which is located through `encryption::KEY::key`, you will need to set this before using the `encryption::encdec::decrypt()` function, since that function grabs from the namespace to use it and the only thing you pass to that function is the string. You must set the key before you call that function. It's not a problem for the `encrypt()` function since it generates a key each time its called. The generated key is the same varible `encryption::KEY::key`. Anytime you need to grab the key or set it, it is there, it will be nowhere else.

main

-288 Bytes
Binary file not shown.

main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ void aesExample() {
3636

3737
//Output key
3838
cout << "Key: ";
39-
for(int i=0; i<sizeof(AESKEY::key)/sizeof(AESKEY::key[0]); ++i) {
40-
cout << AESKEY::key[i] << " ";
39+
for(int i=0; i<sizeof(AES::KEY::key)/sizeof(AES::KEY::key[0]); ++i) {
40+
cout << AES::KEY::key[i] << " ";
4141
};
4242
cout << endl;
4343

@@ -105,8 +105,8 @@ void wholeFileEncryptionExample() {
105105
AES::aes_init(AES::OPTIONS::doGenerateKey);
106106

107107
cout << "Generated key: ";
108-
for(int i=0; i<sizeof(AESKEY::key)/sizeof(AESKEY::key[0]); ++i) {
109-
cout << AESKEY::key[i] << " ";
108+
for(int i=0; i<sizeof(AES::KEY::key)/sizeof(AES::KEY::key[0]); ++i) {
109+
cout << AES::KEY::key[i] << " ";
110110
};
111111
cout << endl << endl << endl;
112112

testFiles/small.aesenc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
xTQ,"}`N,aC_}|}a,jWaV"\TlT^TnELzAWMB^TlTlA,_VpTjE(,jVJr'€"}F<y=,ly,l.j.^,aAWM,"}WJ]€<!:}MGJPABN~~DNF<\A#(WJM:}azxzx`lBN#_B^Va#2;
1+
LB^}@J}r'j'€JM:}L,}j+AzA,]j+.(zAW(HLz='Q.aWJ_y:}p.<yTl aVlz,jVa`aUSJO.aC_\|_:}aFJP=DM#/aXa`€lxDL=A]!."]yBO~)€<\.J}^`LC_:Lzx|1;

0 commit comments

Comments
 (0)