Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
CYPHERS: VIGENERE (encode / decode) a (N_STR / file) with a root key or a combination of a question and an answer

Macros

#define n_mathmod(__a, __b)   ((__a % __b + __b) % __b)
 The % operator returns a result that adopts the sign of the dividend, a true mathematical modulus adopts the sign of the divisor.
 

Functions

N_STRn_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 *rootkey)
 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_STRn_vigenere_decode_qa (N_STR *input_data, N_STR *question, N_STR *answer)
 directly vigenere decode a file using key
 
N_STRn_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 *rootkey)
 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_STRn_vigenere_encode_qa (N_STR *input_data, N_STR *question, N_STR *answer)
 directly vigenere encode a file using key
 
N_STRn_vigenere_get_answer (N_STR *root_key, N_STR *question)
 get an answer from a root key and a question
 
N_STRn_vigenere_get_question (size_t question_size)
 get a question generated from the current machine hardware (disk&cpu)
 
N_STRn_vigenere_get_rootkey (size_t rootkey_size)
 get a rootkey randomly generated
 
N_STRn_vigenere_quick_decode (N_STR *encoded_question)
 quick decode data
 
N_STRn_vigenere_quick_encode (N_STR *decoded_question)
 quick encode data
 

Detailed Description

Macro Definition Documentation

◆ n_mathmod

#define n_mathmod (   __a,
  __b 
)    ((__a % __b + __b) % __b)

The % operator returns a result that adopts the sign of the dividend, a true mathematical modulus adopts the sign of the divisor.

This method implements a mathematical modulus

Definition at line 25 of file n_crypto.h.

Function Documentation

◆ n_vigenere_decode()

N_STR * n_vigenere_decode ( N_STR string,
N_STR key 
)

decode input using vigenere cypher and key

Parameters
stringsource to decode
keykey to use for the encoding/decoding
Returns
a N_STR *decoded

Definition at line 416 of file n_crypto.c.

References n_vigenere_cypher().

Referenced by n_vigenere_quick_decode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_vigenere_decode_file()

int n_vigenere_decode_file ( N_STR in,
N_STR out,
N_STR key 
)

directly vigenere decode a file using key

Parameters
ininput path and filename
outoutput path and filename
keykey to use
Returns
TRUE or FALSE

Definition at line 613 of file n_crypto.c.

References __n_assert, _nstr, file_to_nstr(), free_nstr, LOG_ERR, n_base64_decode(), n_log, n_vigenere_decode_in_place(), and nstr_to_file().

+ Here is the call graph for this function:

◆ n_vigenere_decode_file_qa()

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

Parameters
ininput path and filename
outoutput path and filename
questionquestion key to use
answeranswer key to use
Returns
TRUE or FALSE

Definition at line 733 of file n_crypto.c.

References __n_assert, _nstr, file_to_nstr(), free_nstr, LOG_ERR, n_log, n_vigenere_decode_qa(), and nstr_to_file().

+ Here is the call graph for this function:

◆ n_vigenere_decode_qa()

N_STR * n_vigenere_decode_qa ( N_STR input_data,
N_STR question,
N_STR answer 
)

directly vigenere decode a file using key

Parameters
input_datainput path and filename
questionquestion key to use
answeranswer key to use
Returns
a N_STR *decoded string or NULL

Definition at line 690 of file n_crypto.c.

References __n_assert, N_STR::data, free_nstr, N_STR::length, LOG_DEBUG, LOG_ERR, n_base64_decode(), n_log, n_vigenere_decode_in_place(), n_vigenere_encode(), n_vigenere_quick_decode(), and N_STR::written.

Referenced by n_vigenere_decode_file_qa().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_vigenere_encode()

N_STR * n_vigenere_encode ( N_STR string,
N_STR key 
)

encode input using vigenere cypher and key

Parameters
stringsource to encode
keykey to use for the encoding/decoding
Returns
a N_STR *encoded

Definition at line 406 of file n_crypto.c.

References n_vigenere_cypher().

Referenced by n_vigenere_decode_qa().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_vigenere_encode_file()

int n_vigenere_encode_file ( N_STR in,
N_STR out,
N_STR key 
)

directly vigenere encode a file using key

Parameters
ininput path and filename
outoutput path and filename
keykey to use
Returns
TRUE or FALSE

Definition at line 570 of file n_crypto.c.

References __n_assert, _nstr, file_to_nstr(), free_nstr, LOG_ERR, n_base64_encode(), n_log, n_vigenere_encode_in_place(), and nstr_to_file().

+ Here is the call graph for this function:

◆ n_vigenere_encode_file_qa()

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

Parameters
ininput path and filename
outoutput path and filename
questionquestion key to use
answeranswer key to use
Returns
TRUE or FALSE

Definition at line 762 of file n_crypto.c.

References __n_assert, _nstr, file_to_nstr(), free_nstr, LOG_ERR, n_log, n_vigenere_encode_qa(), and nstr_to_file().

+ Here is the call graph for this function:

◆ n_vigenere_encode_qa()

N_STR * n_vigenere_encode_qa ( N_STR input_data,
N_STR question,
N_STR answer 
)

directly vigenere encode a file using key

Parameters
input_datainput path and filename
questionquestion key to use
answeranswer key to use
Returns
a N_STR *encoded string or NULL

Definition at line 655 of file n_crypto.c.

References __n_assert, free_nstr, LOG_ERR, n_base64_encode(), n_log, n_vigenere_decode_in_place(), n_vigenere_encode_in_place(), and n_vigenere_quick_decode().

Referenced by n_vigenere_encode_file_qa().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_vigenere_get_answer()

N_STR * n_vigenere_get_answer ( N_STR root_key,
N_STR question 
)

get an answer from a root key and a question

Parameters
root_keythe key used to do the inital encoding
questionquestion generated from hardware
Returns
a N_STR *answer_key string

Definition at line 534 of file n_crypto.c.

References __n_assert, N_STR::data, free_nstr, N_STR::length, LOG_ERR, n_log, n_vigenere_quick_decode(), new_nstr(), and N_STR::written.

+ Here is the call graph for this function:

◆ n_vigenere_get_question()

N_STR * n_vigenere_get_question ( size_t  question_size)

get a question generated from the current machine hardware (disk&cpu)

Parameters
question_sizesize of the needed question. Must be a multiple of 2
Returns
a N_STR *question string

Definition at line 477 of file n_crypto.c.

References _nstr, N_STR::data, free_nstr, LOG_ERR, n_base64_encode(), n_get_cpu_id(), n_get_current_dir_hd_serial(), n_log, n_vigenere_quick_encode(), new_nstr(), nstrprintf_cat, and N_STR::written.

+ Here is the call graph for this function:

◆ n_vigenere_get_rootkey()

N_STR * n_vigenere_get_rootkey ( size_t  rootkey_size)

get a rootkey randomly generated

Parameters
rootkey_sizesize of the needed rootkey. Must be a multiple of 2
Returns
a N_STR *rootkey string

Definition at line 49 of file n_crypto.c.

References N_STR::data, LOG_ERR, n_log, new_nstr(), and N_STR::written.

+ Here is the call graph for this function:

◆ n_vigenere_quick_decode()

N_STR * n_vigenere_quick_decode ( N_STR encoded_data)

quick decode data

Parameters
encoded_datathe data to decode
Returns
a N_STR *decoded_data

Definition at line 460 of file n_crypto.c.

References __internal_root_key, char_to_nstr(), free_nstr, n_base64_decode(), and n_vigenere_decode().

Referenced by n_vigenere_decode_qa(), n_vigenere_encode_qa(), and n_vigenere_get_answer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_vigenere_quick_encode()

N_STR * n_vigenere_quick_encode ( N_STR decoded_data)

quick encode data

Parameters
decoded_datathe data to encode
Returns
a N_STR *encoded_data

Definition at line 445 of file n_crypto.c.

References __internal_root_key, char_to_nstr(), free_nstr, n_base64_encode(), and n_vigenere_encode_in_place().

Referenced by n_vigenere_get_question().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: