Nilorea Library
C utilities for networking, threading, graphics
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. More...
 

Functions

N_STRn_vigenere_decode (N_STR *string, N_STR *key)
 decode input using vigenere cypher and key More...
 
int n_vigenere_decode_file (N_STR *in, N_STR *out, N_STR *rootkey)
 directly vigenere decode a file using key More...
 
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 More...
 
N_STRn_vigenere_decode_qa (N_STR *input_data, N_STR *question, N_STR *answer)
 directly vigenere decode a file using key More...
 
N_STRn_vigenere_encode (N_STR *string, N_STR *key)
 encode input using vigenere cypher and key More...
 
int n_vigenere_encode_file (N_STR *in, N_STR *out, N_STR *rootkey)
 directly vigenere encode a file using key More...
 
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 More...
 
N_STRn_vigenere_encode_qa (N_STR *input_data, N_STR *question, N_STR *answer)
 directly vigenere encode a file using key More...
 
N_STRn_vigenere_get_answer (N_STR *root_key, N_STR *question)
 get an answer from a root key and a question More...
 
N_STRn_vigenere_get_question (size_t question_size)
 get a question generated from the current machine hardware (disk&cpu) More...
 
N_STRn_vigenere_get_rootkey (size_t rootkey_size)
 get a rootkey randomly generated More...
 
N_STRn_vigenere_quick_decode (N_STR *encoded_question)
 quick decode data More...
 
N_STRn_vigenere_quick_encode (N_STR *decoded_question)
 quick encode data More...
 

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 26 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 463 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 698 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 837 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 788 of file n_crypto.c.

References __n_assert, free_nstr, LOG_DEBUG, LOG_ERR, n_base64_decode(), n_log, n_vigenere_decode_in_place(), n_vigenere_encode(), and n_vigenere_quick_decode().

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 450 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 648 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 869 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 747 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 605 of file n_crypto.c.

References __n_assert, free_nstr, LOG_ERR, n_log, n_vigenere_quick_decode(), and new_nstr().

+ 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 539 of file n_crypto.c.

References _nstr, 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(), and nstrprintf_cat.

+ 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 LOG_ERR, n_log, and new_nstr().

+ 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 519 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 501 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: