Browse Source

Initial commit

master
Ludovic 'Archivist' Lagouardette 5 years ago
commit
e24c996aff
13 changed files with 113 additions and 0 deletions
  1. +27
    -0
      .vscode/settings.json
  2. +73
    -0
      codebreak.cpp
  3. BIN
      test/46zeros.txt
  4. BIN
      test/46zeros_enc.txt
  5. +5
    -0
      test/data1.txt
  6. +2
    -0
      test/data1_enc.txt
  7. +1
    -0
      test/data2.txt
  8. BIN
      test/data2_enc.txt
  9. +1
    -0
      test/data3.txt
  10. +1
    -0
      test/data3_enc.txt
  11. +1
    -0
      test/data4.txt
  12. +1
    -0
      test/data4_enc.txt
  13. +1
    -0
      test/secondtry.txt

+ 27
- 0
.vscode/settings.json View File

@ -0,0 +1,27 @@
{
"files.associations": {
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp"
}
}

+ 73
- 0
codebreak.cpp View File

@ -0,0 +1,73 @@
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <assert.h>
std::string load_file(std::string filename, size_t end_cut = 0)
{
std::stringstream ret;
std::ifstream file(filename);
while(file.good())
{
ret<<(char)file.get();
}
auto rret = ret.str();
rret.resize(rret.size()-end_cut);
return rret;
}
int main(int argc, char** argv)
{
std::vector<std::string> params;
for(int i=0;i<argc;i++)
{
params.push_back(std::string(argv[i]));
}
if(params.size()==2)
{
auto ciphertext = load_file(params[1],4);
int jumper=0;
bool is_okay = true;
do{
is_okay=true;
for(size_t idx=0;idx<ciphertext.size();idx++)
{
if(!isgraph((char)(ciphertext[idx]-jumper+idx)))
{
is_okay=false;
jumper++;
}
}
}while((!is_okay) && jumper<=256);
if(is_okay)
{
for(size_t idx=0;idx<ciphertext.size();idx++)
{
std::cout<<(char)(ciphertext[idx]-jumper+idx);
}
}else{
std::cout<<"Unable to find a valid representation"<<std::endl;
}
}
else if(params.size()==3)
{
auto ciphertext = load_file(params[1],4);
auto zeroed = load_file(params[2],4);
assert(ciphertext.size()==zeroed.size());
for(size_t idx=0;idx<ciphertext.size();idx++)
{
std::cout<<(char)(ciphertext[idx]-zeroed[idx]);
}
}
else
{
std::cout<<
"codebreak 0.1.0\n"
"usage:\n"
"codebreak encrypted_file [0ed_ciphertext]"
<<std::endl;
}
}

BIN
test/46zeros.txt View File


BIN
test/46zeros_enc.txt View File


+ 5
- 0
test/data1.txt View File

@ -0,0 +1,5 @@
Hello my friend,
This is me!
Good bye ;)

+ 2
- 0
test/data1_enc.txt View File

@ -0,0 +1,2 @@
7U]^bbo^kc`ja*
 Wlny'q|*xq.Y‚ƒy6y‘~:VE]2&

+ 1
- 0
test/data2.txt View File

@ -0,0 +1 @@
Another gorgeous file :D

BIN
test/data2_enc.txt View File


+ 1
- 0
test/data3.txt View File

@ -0,0 +1 @@
abcdefgh

+ 1
- 0
test/data3_enc.txt View File

@ -0,0 +1 @@
*,.02468)d(�

+ 1
- 0
test/data4.txt View File

@ -0,0 +1 @@
hgfedcba

+ 1
- 0
test/data4_enc.txt View File

@ -0,0 +1 @@
11111111j'�

+ 1
- 0
test/secondtry.txt View File

@ -0,0 +1 @@
2XZU^Yc:`fhm\qo FsqpqfmlMtzn��JLD" y桃園2マム

Loading…
Cancel
Save