-
Notifications
You must be signed in to change notification settings - Fork 0
/
ascii-cipher.cpp
30 lines (25 loc) · 1.1 KB
/
ascii-cipher.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
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main() {
string text;
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;
cout << endl << "Enter the text to be ciphered: ";
getline(cin, text);
char arr[text.length()];
int arr2[text.length()];
fstream asciiFile;
asciiFile.open("message.txt", ios::out); //write mode
if (asciiFile.is_open()) {
for (int i = 0; i < text.length(); i++) {
arr[i] = text[i];
arr2[i] = (int)arr[i];
asciiFile << setfill('0') << setw(3) << arr2[i];
}
asciiFile << endl << endl << "ASCII message generated by:" << endl << "Project- ascii-cipher-decipher" << endl << "Author- imsamroy" << endl << "Source code: https://github.com/imsamroy/ascii-cipher-decipher";
}
asciiFile.close();
cout << endl << "The message is stored in the file ('message.txt' in this same folder) in ASCII format" << endl;
cout << "Press enter to exit (If you're on a Windows machine)" << endl;
}