-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprng.txt
46 lines (40 loc) · 920 Bytes
/
prng.txt
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
/// Md.ASADUZZAMAN
/// Dept of ICT
/// MBSTU
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string prng(string s)
{
ll l=s.size();
string s1="",s2="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for(int i=0;i<128;i++)
{
ll x=rand()%26;
s1+=s2[x];
}
return s1;
}
int main()
{
ll n, x, y, a, b, c, t, q;
string s,s1,s2;
while (cin >>s)
{
s2="";
s1=prng(s);
// bug(s1);
cout<<"KEY :"<<s1<<endl;
for(int i=0;i<s.size();i++)
s2+=(char)((ll)s[i]^(ll)s1[i]);
cout<<"ENCRYPTED MESSAGE :"<<s2<<endl;
string s3="";
for(int i=0;i<s2.size();i++)
s3+=(char)((ll)s2[i]^(ll)s1[i]);
cout<<"DECRYPTED MESSAGE :"<<s3<<endl;
}
// end = clock();
// time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
// cout<<"Time spent = "<<time_spent<<endl;
return 0;
}