File tree Expand file tree Collapse file tree 4 files changed +47
-5
lines changed Expand file tree Collapse file tree 4 files changed +47
-5
lines changed Original file line number Diff line number Diff line change
1
+ CXX =g++
2
+ CFLAGS =-I.
3
+
4
+ baby_rev : baby_rev.c
5
+ $(CXX ) -o baby_rev baby_rev.cpp
6
+
7
+ clean :
8
+ $(RM ) baby_rev
Original file line number Diff line number Diff line change
1
+ #include < string>
2
+ #include < iostream>
3
+
4
+ constexpr auto KEY = 42 ;
5
+
6
+ bool is_phrase_correct (std::string_view phrase)
7
+ {
8
+ for (char c : phrase)
9
+ {
10
+ std::cout << static_cast <char >(c ^ KEY) << std::endl;
11
+ }
12
+ }
13
+
14
+ int main ()
15
+ {
16
+
17
+ std::string phrase;
18
+ std::cout << " What's the secret phrase?" << std::endl;
19
+
20
+ std::getline (std::cin, phrase);
21
+
22
+ if (!is_phrase_correct (phrase))
23
+ {
24
+ std::cerr << " Oops try again..." << std::endl;
25
+ return EXIT_FAILURE;
26
+ }
27
+
28
+ std::cout << " Correct!" << std::endl;
29
+
30
+ return EXIT_SUCCESS;
31
+ }
Original file line number Diff line number Diff line change 1
- #include <stdio.h> // For puts and fgets
1
+ #include <stdio.h> // For puts and fgets
2
2
#include <unistd.h> // For execve
3
+ #include <stdlib.h>
3
4
4
- void access_vault () {
5
+ void access_vault ()
6
+ {
5
7
puts ("Access granted" );
6
8
execve ("/bin/sh" , NULL , NULL );
7
9
}
8
10
9
- int main () {
11
+ int main ()
12
+ {
10
13
char input_buffer [16 ];
11
14
puts ("Enter the password to access Santa Ono's secret vault:" );
12
15
13
16
fgets (input_buffer , 32 , stdin ); // Nothing can go wrong here right?
14
17
15
18
puts ("HAHA you thought! There was no password, you can NEVER get in >:)" );
16
19
17
- return 0 ;
18
- }
20
+ return EXIT_SUCCESS ;
21
+ }
You can’t perform that action at this time.
0 commit comments