-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathascii-decipher.cpp
43 lines (37 loc) · 1.24 KB
/
ascii-decipher.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
fstream asciiFile;
string asciiStore;
cout << "ASCII Cipher Decipher (v1.0.1)" << endl << "Project- ascii-cipher-decipher" << endl << "Author- imsamroy" << endl << "Source code: https://github.com/imsamroy/ascii-cipher-decipher" << endl;
asciiFile.open("message.txt", ios::in); //read mode
if (asciiFile.is_open()) {
getline(asciiFile, asciiStore);
}
size_t count = count_if( asciiStore.begin(), asciiStore.end(), []( char c ) { return isdigit( c ); } );
int x = count/3;
cout << endl <<"The message is of: " << x << " characters";
cout << endl << "The message is: ";
char arr[x];
int arr2[x];
string str[asciiStore.length()];
string s;
for (int a = 0; a < asciiStore.length(); a++)
{
str[a] = asciiStore[a];
}
for (int i = 0; i < asciiStore.length(); i = i+3)
{
string s = str[i] + str[i+1] + str[i+2];
for (int j = 0; j < 1; j++)
{
arr2[j] = stoi(s);
arr[j] = (char)arr2[j];
cout << arr[j];
}
}
cout << endl << "Press enter to exit (if you are on a Windows machine)" << endl;
}