/dictionary

a naive but fast and safe dictionary implementation in C

Primary LanguageC

dictionary

a naive but fast and safe dictionary implementation in C

Introduction

This is a BJTU End-of-Term Project for the course "High-level programming language" in Fall Semester, 2022.

dictionary is a simple English-Chinese Dictionary supporting at most 32 (defined by macro SIZE in main.c) 7-character words and 31-character explanations (defined in struct Word in main.c) for each word. It uses Trie to store the dictionary so it is fast and supports fuzzy search by prefix. It supports persistence by storing the dictionary in a file with the following format:

content length
plain data hash EVP_MAX_MD_SIZE (64 bytes)
encrypted data variable length (<= BUF_SIZE = SIZE * sizeof(Word) + EVP_MAX_BLOCK_LENGTH)

The plain data hash is used to check the integrity of the encrypted data and generated by MD5 (defined by macro DIGESTMD in cipher.c). The encrypted data is encrypted by AES-256-CBC (defined by macro CIPHER in cipher.c) with a key and a iv generated by 65536 (defined by macro ROUND in cipher.c) rounds of SHA512 (defined by macro CIPHERMD in cipher.c) with the password provided by the user and the front 8 bytes of the plain data hash as salt.

The plain data is a string of Word structs with the following format:

word1->eng <space> word1->chn <LF> word2->eng <space> word2->chn <LF> ...

All macros and struct mentioned above can be easily modified to support more or longer words and explanations, or to use other encryption algorithms.

Installation

Requirements

  • CMake
  • OpenSSL

Build

mkdir build
cd build
cmake ..
make

Usage

cd build
./dictionary.exe

License

This project is NOT allowed to be used in ANY assignment or academic work, which is considered as plagiarism. Therefore, this repo has no opensource license and is only for reference.

ALL RIGHTS RESERVED BY THE AUTHOR.