blob: b80dd8d523f3b21f75896bbc1c2fcc064bbd68ae (
plain)
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
|
//Stream cipher
disp("In text format:")
disp("Plain text")
disp("Pay 100")
disp("")
disp("Cipher text")
disp("ZTU91 ^%D")
disp("")
disp("")
disp("In binary format:")
disp("Plain text")
pt = "010111001"
disp(pt)
disp("")
//convert to decimal
pt = bin2dec("010111001")
disp("XOR operation with the key")
key="100101011"
disp(key)
//convert key to decimal
key=bin2dec(key)
disp("")
//calculate cipher text
ct = bitxor(pt,key)
ct = dec2bin(ct)
disp("Cipher text")
disp(ct)
disp("")
|