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 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
28#ifndef __N_CRYPTO_H
29#define __N_CRYPTO_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
40#include <stdlib.h>
41#include <memory.h>
42#include "nilorea/n_str.h"
43
45#define n_mathmod(__a, __b) ((__a % __b + __b) % __b)
46
48N_STR* n_vigenere_get_rootkey(size_t rootkey_size);
50N_STR* n_vigenere_get_question(size_t question_size);
52N_STR* n_vigenere_get_answer(N_STR* root_key, N_STR* question);
58N_STR* n_vigenere_quick_encode(N_STR* decoded_question);
60N_STR* n_vigenere_quick_decode(N_STR* encoded_question);
62N_STR* n_vigenere_encode_qa(N_STR* input_data, N_STR* question, N_STR* answer);
64N_STR* n_vigenere_decode_qa(N_STR* input_data, N_STR* question, N_STR* answer);
66int n_vigenere_encode_file(N_STR* in, N_STR* out, N_STR* rootkey);
68int n_vigenere_decode_file(N_STR* in, N_STR* out, N_STR* rootkey);
70int n_vigenere_decode_file_qa(N_STR* in, N_STR* out, N_STR* question, N_STR* answer);
72int n_vigenere_encode_file_qa(N_STR* in, N_STR* out, N_STR* question, N_STR* answer);
73
78#ifdef __cplusplus
79}
80#endif
81/* #ifndef __N_CRYPTO_H */
82#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:705
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:790
N_STR * n_vigenere_quick_encode(N_STR *decoded_question)
quick encode a N_STR using an auto-generated key
Definition n_crypto.c:485
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:456
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:578
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:819
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:747
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:446
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:618
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:662
N_STR * n_vigenere_get_rootkey(size_t rootkey_size)
generate a random root key of given size
Definition n_crypto.c:69
N_STR * n_vigenere_get_question(size_t question_size)
generate a random question of given size
Definition n_crypto.c:517
N_STR * n_vigenere_quick_decode(N_STR *encoded_question)
quick decode a N_STR using an auto-generated key
Definition n_crypto.c:500
A box including a string and his lenght.
Definition n_str.h:61
N_STR and string function declaration.