6 n__crypto_8h
gullradriel edited this page 2026-10-09 00:55:18 +02:00

include/nilorea/n_crypto.h

Vigenere encoding and decoding functions using N_STR/files. More...

Detailed Description

Vigenere encoding and decoding functions using N_STR/files.

Author: Castagnier Mickael

Version: 1.0

Date: 10/11/2022

Source code

/*
 * Nilorea Library
 * Copyright (C) 2005-2026 Castagnier Mickael
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */


#ifndef __N_CRYPTO_H
#define __N_CRYPTO_H

#ifdef __cplusplus
extern "C" {
#endif


#include <stdlib.h>
#include <memory.h>
#include "nilorea/n_str.h"

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

N_STR* n_vigenere_get_rootkey(size_t rootkey_size);
N_STR* n_vigenere_get_question(size_t question_size);
N_STR* n_vigenere_get_answer(N_STR* root_key, N_STR* question);
N_STR* n_vigenere_encode(N_STR* string, N_STR* key);
N_STR* n_vigenere_decode(N_STR* string, N_STR* key);
N_STR* n_vigenere_quick_encode(N_STR* decoded_question);
N_STR* n_vigenere_quick_decode(N_STR* encoded_question);
N_STR* n_vigenere_encode_qa(N_STR* input_data, N_STR* question, N_STR* answer);
N_STR* n_vigenere_decode_qa(N_STR* input_data, N_STR* question, N_STR* answer);
int n_vigenere_encode_file(N_STR* in, N_STR* out, N_STR* rootkey);
int n_vigenere_decode_file(N_STR* in, N_STR* out, N_STR* rootkey);
int n_vigenere_decode_file_qa(N_STR* in, N_STR* out, N_STR* question, N_STR* answer);
int n_vigenere_encode_file_qa(N_STR* in, N_STR* out, N_STR* question, N_STR* answer);


#ifdef __cplusplus
}
#endif
/* #ifndef __N_CRYPTO_H */
#endif