6 Module CYPHER_VIGENERE
gullradriel edited this page 2026-10-29 20:54:40 +01:00

CYPHERS: VIGENERE (encode / decode) a (N_STR / file) with a root key or a combination of a question and an answer

Functions

Name
N_STR * n_vigenere_quick_encode(N_STR * decoded_question)
quick encode a N_STR using an auto-generated key
N_STR * n_vigenere_quick_decode(N_STR * encoded_question)
quick decode a N_STR using an auto-generated key
N_STR * n_vigenere_get_rootkey(size_t rootkey_size)
generate a random root key of given size
N_STR * n_vigenere_get_question(size_t question_size)
generate a random question of given size
N_STR * n_vigenere_get_answer(N_STR * root_key, N_STR * question)
compute the answer from a root key and a question
N_STR * n_vigenere_encode_qa(N_STR * input_data, N_STR * question, N_STR * answer)
encode a N_STR using vigenere cipher with a question and answer pair
int n_vigenere_encode_file_qa(N_STR * in, N_STR * out, N_STR * question, N_STR * answer)
encode a file using vigenere cipher with a question and answer pair
int n_vigenere_encode_file(N_STR * in, N_STR * out, N_STR * rootkey)
encode a file using vigenere cipher with a root key
N_STR * n_vigenere_encode(N_STR * string, N_STR * key)
encode a N_STR using vigenere cipher with the given key
N_STR * n_vigenere_decode_qa(N_STR * input_data, N_STR * question, N_STR * answer)
decode a N_STR using vigenere cipher with a question and answer pair
int n_vigenere_decode_file_qa(N_STR * in, N_STR * out, N_STR * question, N_STR * answer)
decode a file using vigenere cipher with a question and answer pair
int n_vigenere_decode_file(N_STR * in, N_STR * out, N_STR * rootkey)
decode a file using vigenere cipher with a root key
N_STR * n_vigenere_decode(N_STR * string, N_STR * key)
decode a N_STR using vigenere cipher with the given key

Defines

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

Functions Documentation

function n_vigenere_quick_encode

N_STR * n_vigenere_quick_encode(
    N_STR * decoded_question
)

quick encode a N_STR using an auto-generated key

Parameters:

  • decoded_data the data to encode

Return: a N_STR *encoded_data

quick encode data

quick encode a N_STR using an auto-generated key

function n_vigenere_quick_decode

N_STR * n_vigenere_quick_decode(
    N_STR * encoded_question
)

quick decode a N_STR using an auto-generated key

Parameters:

  • encoded_data the data to decode

Return: a N_STR *decoded_data

quick decode data

quick decode a N_STR using an auto-generated key

function n_vigenere_get_rootkey

N_STR * n_vigenere_get_rootkey(
    size_t rootkey_size
)

generate a random root key of given size

Parameters:

  • rootkey_size size of the needed rootkey. Must be a multiple of 2

Return: a N_STR *rootkey string

get a rootkey randomly generated

generate a random root key of given size

function n_vigenere_get_question

N_STR * n_vigenere_get_question(
    size_t question_size
)

generate a random question of given size

Parameters:

  • question_size size of the needed question. Must be a multiple of 2

Return: a N_STR *question string

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

generate a random question of given size

function n_vigenere_get_answer

N_STR * n_vigenere_get_answer(
    N_STR * root_key,
    N_STR * question
)

compute the answer from a root key and a question

Parameters:

  • root_key the key used to do the inital encoding
  • question question generated from hardware

Return: a N_STR *answer_key string

get an answer from a root key and a question

compute the answer from a root key and a question

function n_vigenere_encode_qa

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

encode a N_STR using vigenere cipher with a question and answer pair

Parameters:

  • input_data input path and filename
  • question question key to use
  • answer answer key to use

Return: a N_STR *encoded string or NULL

directly vigenere encode a file using key

encode a N_STR using vigenere cipher with a question and answer pair

function n_vigenere_encode_file_qa

int n_vigenere_encode_file_qa(
    N_STR * in,
    N_STR * out,
    N_STR * question,
    N_STR * answer
)

encode a file using vigenere cipher with a question and answer pair

Parameters:

  • in input path and filename
  • out output path and filename
  • question question key to use
  • answer answer key to use

Return: TRUE or FALSE

directly vigenere encode a file using question and answer

encode a file using vigenere cipher with a question and answer pair

function n_vigenere_encode_file

int n_vigenere_encode_file(
    N_STR * in,
    N_STR * out,
    N_STR * rootkey
)

encode a file using vigenere cipher with a root key

Parameters:

  • in input path and filename
  • out output path and filename
  • key key to use

Return: TRUE or FALSE

directly vigenere encode a file using key

encode a file using vigenere cipher with a root key

function n_vigenere_encode

N_STR * n_vigenere_encode(
    N_STR * string,
    N_STR * key
)

encode a N_STR using vigenere cipher with the given key

Parameters:

  • string source to encode
  • key key to use for the encoding/decoding

Return: a N_STR *encoded

encode input using vigenere cypher and key

encode a N_STR using vigenere cipher with the given key

function n_vigenere_decode_qa

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

decode a N_STR using vigenere cipher with a question and answer pair

Parameters:

  • input_data input path and filename
  • question question key to use
  • answer answer key to use

Return: a N_STR *decoded string or NULL

directly vigenere decode a file using key

decode a N_STR using vigenere cipher with a question and answer pair

function n_vigenere_decode_file_qa

int n_vigenere_decode_file_qa(
    N_STR * in,
    N_STR * out,
    N_STR * question,
    N_STR * answer
)

decode a file using vigenere cipher with a question and answer pair

Parameters:

  • in input path and filename
  • out output path and filename
  • question question key to use
  • answer answer key to use

Return: TRUE or FALSE

directly vigenere decode a file using question and answer

decode a file using vigenere cipher with a question and answer pair

function n_vigenere_decode_file

int n_vigenere_decode_file(
    N_STR * in,
    N_STR * out,
    N_STR * rootkey
)

decode a file using vigenere cipher with a root key

Parameters:

  • in input path and filename
  • out output path and filename
  • key key to use

Return: TRUE or FALSE

directly vigenere decode a file using key

decode a file using vigenere cipher with a root key

function n_vigenere_decode

N_STR * n_vigenere_decode(
    N_STR * string,
    N_STR * key
)

decode a N_STR using vigenere cipher with the given key

Parameters:

  • string source to decode
  • key key to use for the encoding/decoding

Return: a N_STR *decoded

decode input using vigenere cypher and key

decode a N_STR using vigenere cipher with the given key

Macros Documentation

define 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