![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Vigenere encode decode function. More...
#include "nilorea/n_common.h"#include "nilorea/n_base64.h"#include "nilorea/n_crypto.h"#include "nilorea/n_thread_pool.h"#include <stdio.h>#include <string.h>#include <ctype.h>#include <sys/sysinfo.h>
Include dependency graph for n_crypto.c:Go to the source code of this file.
Data Structures | |
| struct | CYPHER_PARAM |
| structure of a n_vigenere_cypher_thread param More... | |
Macros | |
| #define | _GNU_SOURCE |
| #define | _GNU_SOURCE_WAS_NOT_DEFINED |
Functions | |
| N_STR * | n_get_cpu_id () |
| get the CPU id | |
| N_STR * | n_get_current_dir_hd_serial () |
| get the serial of the current running dir hosting disk | |
| N_STR * | n_vigenere_cypher (N_STR *input, N_STR *key, bool encipher, bool in_place) |
| encode or decode input using vigenere cypher | |
| void * | n_vigenere_cypher_thread (void *ptr) |
| encode or decode threaded func using params from ptr | |
| N_STR * | n_vigenere_decode (N_STR *string, N_STR *key) |
| decode input using vigenere cypher and key | |
| int | n_vigenere_decode_file (N_STR *in, N_STR *out, N_STR *key) |
| directly vigenere decode a file using key | |
| int | n_vigenere_decode_file_qa (N_STR *in, N_STR *out, N_STR *question, N_STR *answer) |
| directly vigenere decode a file using question and answer | |
| N_STR * | n_vigenere_decode_in_place (N_STR *string, N_STR *key) |
| decode input using vigenere cypher and key | |
| N_STR * | n_vigenere_decode_qa (N_STR *input_data, N_STR *question, N_STR *answer) |
| directly vigenere decode a file using key | |
| N_STR * | n_vigenere_encode (N_STR *string, N_STR *key) |
| encode input using vigenere cypher and key | |
| int | n_vigenere_encode_file (N_STR *in, N_STR *out, N_STR *key) |
| directly vigenere encode a file using key | |
| int | n_vigenere_encode_file_qa (N_STR *in, N_STR *out, N_STR *question, N_STR *answer) |
| directly vigenere encode a file using question and answer | |
| N_STR * | n_vigenere_encode_in_place (N_STR *string, N_STR *key) |
| encode string in place using vigenere cypher and key | |
| N_STR * | n_vigenere_encode_qa (N_STR *input_data, N_STR *question, N_STR *answer) |
| directly vigenere encode a file using key | |
| N_STR * | n_vigenere_get_answer (N_STR *root_key, N_STR *question) |
| get an answer from a root key and a question | |
| N_STR * | n_vigenere_get_question (size_t question_size) |
| get a question generated from the current machine hardware (disk&cpu) | |
| N_STR * | n_vigenere_get_rootkey (size_t rootkey_size) |
| get a rootkey randomly generated | |
| N_STR * | n_vigenere_quick_decode (N_STR *encoded_data) |
| quick decode data | |
| N_STR * | n_vigenere_quick_encode (N_STR *decoded_data) |
| quick encode data | |
Variables | |
| static char * | __internal_root_key = "ENOFGLUCUNZJADRDMCZZSACRBKXAGSLTTFCICPALKHMWWGLVUIFYSLQJIHHXSHOZGRABFNBHGVTOMEBTVIPXZJHHEKIYWNVTWQKERROCTXFGMMLYUJSJFWLFCHQQMMUM" |
| static internal root key, just to obfuscate text so we do not care if is is public | |
| struct CYPHER_PARAM |
structure of a n_vigenere_cypher_thread param
Definition at line 217 of file n_crypto.c.
Collaboration diagram for CYPHER_PARAM:| Data Fields | ||
|---|---|---|
| N_STR * | dest | destination |
| bool | encipher | 1 encoding, 0 decoding |
| size_t | end_pos | output starting point |
| N_STR * | input | input data |
| N_STR * | key | encoding/decoding key |
| size_t | start_pos | input starting point |
| #define _GNU_SOURCE |
Definition at line 10 of file n_crypto.c.
| #define _GNU_SOURCE_WAS_NOT_DEFINED |
Definition at line 11 of file n_crypto.c.
| N_STR * n_get_cpu_id | ( | ) |
get the CPU id
Definition at line 134 of file n_crypto.c.
References LOG_ERR, n_log, and nstrprintf.
Referenced by n_vigenere_get_question().
Here is the caller graph for this function:| N_STR * n_get_current_dir_hd_serial | ( | ) |
get the serial of the current running dir hosting disk
Definition at line 73 of file n_crypto.c.
References _nstr, _str, N_STR::data, Free, free_nstr, LOG_ERR, n_log, n_popen(), nstrprintf, and N_STR::written.
Referenced by n_vigenere_get_question().
Here is the call graph for this function:
Here is the caller graph for this function:encode or decode input using vigenere cypher
| input | source to encode/decode |
| key | key to use for the encoding/decoding |
| encipher | bool, set to 1 => encode, 0 => decode |
| in_place | bool, set to 1 => use input as output string , 0 return a new encoded copy |
Definition at line 289 of file n_crypto.c.
References __n_assert, _nstr, add_threaded_process(), N_STR::data, CYPHER_PARAM::dest, destroy_threaded_pool(), DIRECT_PROC, CYPHER_PARAM::encipher, CYPHER_PARAM::end_pos, CYPHER_PARAM::input, key, CYPHER_PARAM::key, LOG_ERR, Malloc, n_log, n_vigenere_cypher_thread(), new_thread_pool(), nstrdup(), refresh_thread_pool(), CYPHER_PARAM::start_pos, thread_pool, wait_for_threaded_pool(), and N_STR::written.
Referenced by n_vigenere_decode(), n_vigenere_decode_in_place(), n_vigenere_encode(), and n_vigenere_encode_in_place().
Here is the call graph for this function:
Here is the caller graph for this function:| void * n_vigenere_cypher_thread | ( | void * | ptr | ) |
encode or decode threaded func using params from ptr
| ptr | a CYPHER_PARAM *param struc |
Definition at line 237 of file n_crypto.c.
References __n_assert, N_STR::data, CYPHER_PARAM::dest, CYPHER_PARAM::encipher, CYPHER_PARAM::end_pos, Free, CYPHER_PARAM::input, key, CYPHER_PARAM::key, n_islower(), n_isupper(), n_mathmod, n_tolower(), n_toupper(), and CYPHER_PARAM::start_pos.
Referenced by n_vigenere_cypher().
Here is the call graph for this function:
Here is the caller graph for this function:decode input using vigenere cypher and key
| string | source to decode |
| key | key to use for the encoding/decoding |
Definition at line 437 of file n_crypto.c.
References key, and n_vigenere_cypher().
Referenced by n_vigenere_decode_file(), n_vigenere_decode_qa(), and n_vigenere_encode_qa().
Here is the call graph for this function:
Here is the caller graph for this function:encode string in place using vigenere cypher and key
| string | source to encode |
| key | key to use for the encoding/decoding |
Definition at line 427 of file n_crypto.c.
References key, and n_vigenere_cypher().
Referenced by n_vigenere_encode_file(), n_vigenere_encode_qa(), and n_vigenere_quick_encode().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
static internal root key, just to obfuscate text so we do not care if is is public
Definition at line 43 of file n_crypto.c.
Referenced by n_vigenere_quick_decode(), and n_vigenere_quick_encode().