How to run this C++ code in ubuntu?
I have compiled this code: https://github.com/vbdaga/Rabbit-Cipher/blob/master/rabbit.cpp
with g++ rabbit.cpp -o Rabbit
but there are nowhere instructions on how to pass the arguments. I see only getline
which do not help… I use Ubuntu 22.04.2 if that helps… Does anyone has any idea how to proceed?
The rabbit.cpp
file appears to contain a minimal test program for the encryption library – you can pass it arguments, but it will ignore them:
$ g++ -Wunused-parameter -o Rabbit rabbit.cpp
rabbit.cpp: In function ‘int main(int, const char**)’:
rabbit.cpp:9:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
9 | int main(int argc, char const *argv[])
| ~~~~^~~~
rabbit.cpp:9:32: warning: unused parameter ‘argv’ [-Wunused-parameter]
9 | int main(int argc, char const *argv[])
| ~~~~~~~~~~~~^~~~~~
Instead, it reads parameters from the input.txt
file:
key:
2115 55464 876543 3213 6456 79 6546 312
IV:
654897 32135
plaintext_size:
300000000
(well technically it reads from std::cin
, after reopening input.txt
on the standard input stream). As shipped, it doesn’t provide any means to enter plaintext – it simply stuffs the plaintext
vector with plaintext_size
zero bytes:
vector <unsigned int> plaintext;
int len;
cin>>len;
for(int i=0;i<len;i++){
int x;
//cin>>x;
plaintext.push_back(0);
}
With the given plaintext_size
of 300000000 that will produce an extremely large ciphertext output.
If you want to verify that the program works as intended, I suggest you modify input.txt
corresponding to the example in the README.md
file:
### Example
key1 = [0000 0000 0000 0000 0000 0000 0000 0000]
plain_text = [0000 0000 0000 0000 ]
iv = [0000 0000]
cipher_text = [ED B7 05 67 37 5D CD 7C D8 95 54 F8 5E 27 A7 C6]
i.e.
$ cat input.txt
key:
0000 0000 0000 0000 0000 0000 0000 0000
IV:
0000 0000
plaintext_size:
4
Then ./Rabbit
should produce the following output.txt
:
$ cat output.txt
01100111000001011011011111101101
01111100110011010101110100110111
11111000010101001001010111011000
11000110101001110010011101011110
which you can confirm contains the expected ciphertext bytes for example using
$ perl -ne 'printf "%Xn", unpack("L", pack("B*", $_))' output.txt
EDB70567
375DCD7C
D89554F8
5E27A7C6