2016-04-21 13:59:08 -07:00
No More Secrets
===============
2016-04-26 08:40:42 -07:00
"No More Secrets" is the name I've lovingly given to the infamous "decrypting text" effect seen on
screen in the 1992 hacker movie Sneakers. If you are unfamiliar with the effect, it can be seen
2016-04-28 03:33:30 -07:00
at 0:35 in [this youtube video ](https://www.youtube.com/watch?v=F5bAa6gFvLs&t=35 ).
2016-04-25 10:40:19 -07:00
2016-04-26 08:40:42 -07:00
This project provides tools to recreate this effect in your projects.
2016-04-25 10:40:19 -07:00
2016-04-26 08:40:42 -07:00
Here is a standalone executable called `nms` (provided in this project) that uses these tools to
perform this effect on piped data:
2016-04-25 11:14:28 -07:00
![Screenshot ](http://i.imgur.com/ezF3xkN.gif )
2016-05-01 13:17:04 -07:00
Also included in this project is a program called `sneakers` that utilizes these tools to recreate,
almost identically, what we see in the above movie clip.
2016-04-25 10:41:19 -07:00
2016-04-25 10:40:19 -07:00
![Screenshot ](http://www.tackboard.world/no_more_secrets.gif )
2016-04-21 13:59:08 -07:00
2016-04-22 13:25:21 -07:00
What's Provided
---------------
2016-04-25 10:49:53 -07:00
Two tools are provided for you to recreate this effect:
2016-04-22 13:13:39 -07:00
2016-04-26 08:40:42 -07:00
1. A standalone executable file named `nms` (shown above). This program performs the "decrypting text" effect on data it receives via shell pipe.
2016-04-22 13:13:39 -07:00
2016-04-26 08:40:42 -07:00
2. A module and header file, written in C, that can be used to recreate this effect in other projects. In fact, the standalone executable `nms` is really just an example that shows how to use this module with piped data.
2016-04-22 13:25:21 -07:00
2016-04-22 13:34:40 -07:00
Installing the Standalone Executable
------------------------------------
2016-04-26 11:22:34 -07:00
First, make sure you have the ncurses library installed:
```
ls /usr/include | grep ncurses.h
```
If the ncurses.h header file is not present, you may need to install the library. On Ubuntu, type:
```
sudo apt-get update
2016-05-12 12:06:35 -07:00
sudo apt-get install lib32ncurses5-dev lib32ncursesw5-dev
2016-04-26 11:22:34 -07:00
```
If you are using a different flavor of linux, search your available packages for "ncurses" and install
2016-05-12 12:06:35 -07:00
it. If you see two different packages for "ncurses" and "ncursesw", install them both (as shown above
in the Ubuntu example).
2016-04-26 11:22:34 -07:00
Next, download and build the standalone executable:
2016-04-21 13:59:08 -07:00
```
git clone https://github.com/bartobri/no-more-secrets.git
cd ./no-more-secrets
make
2016-05-01 13:12:03 -07:00
sudo make install
2016-04-21 13:59:08 -07:00
```
2016-05-01 13:12:03 -07:00
This will create and install an executable file `nms` . (Note that this also installs another
executable file named `sneakers` which is shown above.)
2016-04-21 13:59:08 -07:00
2016-04-22 13:40:16 -07:00
Using the Standalone Executable
-------------------------------
2016-04-21 13:59:08 -07:00
2016-04-22 13:40:16 -07:00
`nms` accepts data from a shell pipe. Simply pipe some data to it and enjoy the magic!
2016-04-21 13:59:08 -07:00
```
2016-05-01 13:12:03 -07:00
ls -l / | nms
2016-04-21 13:59:08 -07:00
```
Once the "encrypted" data is displayed, the program will pause until you press a key. Then the
2016-04-22 13:40:16 -07:00
decryption effect will start. After that is completed, it will again pause until
2016-04-21 13:59:08 -07:00
you press a key, at which point the program will terminate.
2016-04-22 13:25:21 -07:00
2016-05-01 14:09:38 -07:00
#### Command Line Options
Use the `-a` option to set the auto_decrypt flag. This will automatically start the decryption effect,
eliminating the need for the user to press a key to start it.
```
ls -l / | nms -a
```
2016-05-03 07:30:11 -07:00
Use the `-f` option to set foreground color to either white, yellow, black, magenta, blue, green, or
red - this is blue by default.
2016-05-02 05:33:19 -07:00
```
ls -l / | nms -f green
```
2016-04-25 15:19:14 -07:00
Using the Module in Your Program
2016-04-25 13:45:52 -07:00
---------------------------------
2016-04-26 11:22:34 -07:00
NOTE: Be sure that you have the ncurses library installed on your system. See "Installing the
Standalone Executable" above for more info.
2016-04-25 14:41:17 -07:00
#### Synopsis
2016-04-25 14:40:09 -07:00
```
2016-04-25 14:45:04 -07:00
// myprog.c
2016-04-25 14:40:09 -07:00
#include "nms.h"
int main() {
NmsArgs args = INIT_NMSARGS;
args.src = "This is a simple test";
nms_exec(&args);
return 0;
}
```
2016-04-25 14:45:04 -07:00
Compile myprog.c (must include `nms.c` and `-lncurses` ):
2016-04-25 14:40:09 -07:00
```
2016-04-25 14:45:04 -07:00
gcc nms.c myprog.c -o myprog -lncurses
2016-04-25 14:40:09 -07:00
```
2016-04-26 08:40:42 -07:00
#### How-To
2016-04-25 14:40:09 -07:00
2016-04-25 15:10:43 -07:00
Copy these two files to your project:
2016-04-25 13:45:52 -07:00
```
nms.h
nms.c
```
Include `nms.h` in your program file:
```
2016-04-26 08:40:42 -07:00
#include "nms.h"
2016-04-25 14:18:43 -07:00
```
2016-04-26 08:50:59 -07:00
Next, declare and initialize the structure that needs to be passed to `nms_exec()` :
2016-04-25 14:18:43 -07:00
```
NmsArgs args = INIT_NMSARGS;
```
2016-04-26 08:50:59 -07:00
INIT_NMSARGS is a defined name that assigns a default set of values to all of the structure members. It
2016-04-26 08:40:42 -07:00
is recommended that you use it. If you don't, you will have to manually assign a value to each
structure member.
2016-04-26 09:19:17 -07:00
Here is how the structure is defined:
2016-04-25 14:18:43 -07:00
```
typedef struct {
char *src;
2016-05-03 07:30:11 -07:00
char *foreground_color;
2016-04-25 14:18:43 -07:00
char *return_opts;
int input_cursor_x;
int input_cursor_y;
bool show_cursor;
2016-05-01 14:09:38 -07:00
bool auto_decrypt;
2016-04-25 14:18:43 -07:00
} NmsArgs;
```
2016-04-26 08:50:59 -07:00
* `char *src`
2016-04-26 08:57:18 -07:00
* Pointer to the string of characters on which to perform the effect.
2016-05-03 07:30:11 -07:00
* `char *foreground_color`
* Pointer to a string containing the desired foreground color: white, yellow, black, magenta, blue, green, red.
2016-04-26 08:50:59 -07:00
* `char *return_opts`
2016-04-26 09:19:17 -07:00
* String pointer containing only the character options that the user must choose from once the src characters are revealed. For example, if you are showing a menu with six options, this string might be "123456". The user will have to choose one of these characters before execution is handed back to the calling function. Note that the character selected is returned by `nms_exec()` ;
2016-04-26 08:50:59 -07:00
* `int input_cursor_x` and `int input_cursor_y`
2016-04-26 09:19:17 -07:00
* If your menu has a specific location that you'd like to place the cursor for user input, use these to set the x and y screen coordinates for the position.
2016-04-26 08:50:59 -07:00
* `bool show_cursor`
2016-04-26 08:57:18 -07:00
* Set to `true` if you want the cursor to be visible during the text decryption effect. It is set to `false` by default.
2016-05-01 14:09:38 -07:00
* `bool auto_decrypt`
* Set to `true` to automatically start the decryption effect, eliminating the need for the user to press a key to start it.
2016-04-25 15:10:43 -07:00
2016-04-26 08:40:42 -07:00
Assign values to the structure members as needed. Then simply pass a pointer to the structure to the
nms_exec() function:
```
nms_exec(&args);
```
Note that nms_exec() prompts the user to press a key to start the "decrypting text" effect, and again
once the text has been fully revealed. The key that is pressed at the second prompt is returned to the
calling function so that it can be used as input after displaying a menu.
2016-04-25 15:10:43 -07:00
#### Compiling
Add `nms.c` to your source file list, and link the ncurses library `-lncurses` when compiling:
```
gcc nms.c myprog.c -o myprog -lncurses
```
2016-04-25 13:45:52 -07:00
2016-04-22 13:25:21 -07:00
License
-------
This program is free software; you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version. See [COPYING ](COPYING ) for more details.