Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Encryption/Encryption.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Encryption" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/Encryption" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/Encryption" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
7 changes: 7 additions & 0 deletions Encryption/Encryption.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# depslib dependency file v1.0
1567875542 source:c:\users\user\desktop\codeblocks\encryption\main.cpp
<iostream>
<ctime>
<cstdlib>
<string>

10 changes: 10 additions & 0 deletions Encryption/Encryption.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1003" topLine="9" />
</Cursor>
</File>
</CodeBlocks_layout_file>
Binary file added Encryption/bin/Debug/Encryption.exe
Binary file not shown.
29 changes: 29 additions & 0 deletions Encryption/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>

using namespace std;

string toBeEncrypted (string Text)
{
int genKey, counter = 0, enResult[( (Text.length() ) *2)]; //declaring random key to encrypt, counter for loops, array to facilitate conversion on integer into char
string Temp = ""; //declare empty string to be returned

srand(time(0));//initialise rand

genKey = ((rand() % 10) + 1);//get random number to encrypt

Temp = Temp + (char)((genKey) + 100);//add encryption number as char (added 100 to prevent help encryption

for (int i = 1; i <= ( (Text.length() ) *2 ); i+=2)//main loop for encrypting characters one at a time
{
enResult[i] = (((int)Text[counter]) % genKey);
enResult[i+1] = (((int)Text[counter]) / genKey);
counter++;
Temp = Temp + (char)(enResult[i] + 100);
Temp = Temp + (char)(enResult[i+1] + 100);
}

return Temp;//return the encrypted message
}
Binary file added Encryption/obj/Debug/main.o
Binary file not shown.