Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_crypto.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#ifndef __N_CRYPTO_H
28#define __N_CRYPTO_H
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
39#include <stdlib.h>
40#include <memory.h>
41#include "nilorea/n_str.h"
42
44#define n_mathmod(__a, __b) ((__a % __b + __b) % __b)
45
47N_STR* n_vigenere_get_rootkey(size_t rootkey_size);
49N_STR* n_vigenere_get_question(size_t question_size);
51N_STR* n_vigenere_get_answer(N_STR* root_key, N_STR* question);
57N_STR* n_vigenere_quick_encode(N_STR* decoded_question);
59N_STR* n_vigenere_quick_decode(N_STR* encoded_question);
61N_STR* n_vigenere_encode_qa(N_STR* input_data, N_STR* question, N_STR* answer);
63N_STR* n_vigenere_decode_qa(N_STR* input_data, N_STR* question, N_STR* answer);
65int n_vigenere_encode_file(N_STR* in, N_STR* out, N_STR* rootkey);
67int n_vigenere_decode_file(N_STR* in, N_STR* out, N_STR* rootkey);
69int n_vigenere_decode_file_qa(N_STR* in, N_STR* out, N_STR* question, N_STR* answer);
71int n_vigenere_encode_file_qa(N_STR* in, N_STR* out, N_STR* question, N_STR* answer);
72
77#ifdef __cplusplus
78}
79#endif
80/* #ifndef __N_CRYPTO_H */
81#endif
char * key
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
Definition n_crypto.c:704
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
Definition n_crypto.c:789
N_STR * n_vigenere_quick_encode(N_STR *decoded_question)
quick encode a N_STR using an auto-generated key
Definition n_crypto.c:484
N_STR * n_vigenere_decode(N_STR *string, N_STR *key)
decode a N_STR using vigenere cipher with the given key
Definition n_crypto.c:455
N_STR * n_vigenere_get_answer(N_STR *root_key, N_STR *question)
compute the answer from a root key and a question
Definition n_crypto.c:577
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
Definition n_crypto.c:818
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
Definition n_crypto.c:746
N_STR * n_vigenere_encode(N_STR *string, N_STR *key)
encode a N_STR using vigenere cipher with the given key
Definition n_crypto.c:445
int n_vigenere_encode_file(N_STR *in, N_STR *out, N_STR *rootkey)
encode a file using vigenere cipher with a root key
Definition n_crypto.c:617
int n_vigenere_decode_file(N_STR *in, N_STR *out, N_STR *rootkey)
decode a file using vigenere cipher with a root key
Definition n_crypto.c:661
N_STR * n_vigenere_get_rootkey(size_t rootkey_size)
generate a random root key of given size
Definition n_crypto.c:68
N_STR * n_vigenere_get_question(size_t question_size)
generate a random question of given size
Definition n_crypto.c:516
N_STR * n_vigenere_quick_decode(N_STR *encoded_question)
quick decode a N_STR using an auto-generated key
Definition n_crypto.c:499
A box including a string and his lenght.
Definition n_str.h:60
N_STR and string function declaration.