C++ Programming GalleryMath and others

Text encryptor and decryptor in C++

A program that encrypts an ACSII text document, using the Gaussian function Pi(x) and the function Primo(n).

Where:

  • Pi(x) is the number of primes less than or equal to a positive number x.
    E.g. Pi(4)= 2 ; Pi(20)=8
  • Primo(n) is the n-th prime counted starting from 1
    Exm Primo(11)=29

Algorithm:

If “character” is an ASCII then 0<=character<=255.

Then: character = prime + residue

prime is the least prime number immediately less than character

where prime = Primo( argument )

and argument = Pi(character)

So any number can be represented only by its argument (arg) and by its residue (res).

Exm: if character=’U’ (character=85)

85 = 83 + 2 = Primo( Pi(24) ) + 2

Then: 85 is represented by -> arg=24 and res=2

Some Bugs fixed
Arg and res are increased by 32 so their values are not between 0 and 32 since fscanf does not read ASCII characters in that range.

So in the example:

arg=32+24=56 (corresponding to ASCII ‘7’)
res=32+2=34 (corresponding to ACSII ‘”‘)

Developed by:

JOSE LUIS DE LA CRUZ LAZARO

YACSHA – Software & Desing, since 1999, Lima – Perú
The World of Chaos – EL MUNDO DEL CAOS – Unlimited Programming

You can DOWNLOAD the SOURCE CODE and executable software for FREE from here:

Join The World of Chaos Developer Community😃

Contribute to the project on Github!

HISTORY

  • Version 3 – 22-IV-2024
    • The modern C++ ifstream and ofstream classes are used, instead of the old C language FILE library, to read and write binary files.
  • Version 2 – 19-IV-2024
    • Update math-and-others\encripta – Porting to VC++ 2017 using winbgi
    • Using strcpy_s and strcat_s instead old and not secure strcpy and strcat
  • Version 1 – 10-VI-1999
    • First version for Borland C++ 3.1 and Turbo C 3.0

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button