-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecoder.cpp
More file actions
49 lines (42 loc) · 1.05 KB
/
decoder.cpp
File metadata and controls
49 lines (42 loc) · 1.05 KB
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
44
45
46
47
48
49
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
#include "helper.h"
void data_read(string &s, vector<int> &coeffs){
ifstream f("links.txt");
if (!f.is_open()){
cerr<<"Error opening the file!";
return;
}
getline(f,s);
string temp;
while(f>>temp){
coeffs.push_back(stoi(temp));
}
f.close();
}
int main(){
string enc_link;
vector<int> coeffs;
try{
data_read(enc_link,coeffs);
cout<<"Enter Roll number:";
string key;cin>>key;
int key_num = poly_hash(key);
int final_key = eval_poly(coeffs,key_num);
//cout<<final_key<<endl;
string link = enc_dec(enc_link,final_key);
if(link.substr(0,21)!="https://chat.whatsapp"){
cout<<"There's still a bug mate"<<endl;
}else{
cout<<link<<endl;
}
}
catch(const exception &e){
cerr<<"Error sir: "<<e.what()<<endl;
}
return 0;
}