FmgLib.Cryption

Last updated: 08 Eyl 2024

FmgLib.Cryption

This package provides encryption operations. In order to include the package in the project; From the Program.cs file:

builder.Services.AddFmgLibCryption("jsonPath");

code should be added.

public class MyClass
{
     ICryption _cryption;
     IPasswordCryption _passwordCryption;

     public MyClass(ICryption cryption, IPasswordCryption passwordCryption)
     {
         _cryption = cryption;
         _passwordCryption = passwordCryption;
     }

     public void crypt()
     {
         var temp = _cryption.Encryption("Hello, World!");
         Console.WriteLine();
         Console.WriteLine(_cryption.Decryption(temp));
     }
}

you can use it easily.

Or if you don't want to add it via Program.cs, you can use it like this;

public class MyClass
{
     Cryption _cryption = new Cryption();
     PasswordCryption _passwordCryption = new PasswordCryption();

     public void crypt()
     {
         var temp = _cryption.Encryption("Hello, World!");
         Console.WriteLine();
         Console.WriteLine(_cryption.Decryption(temp));
     }
}

It encrypts according to the string you have specified and the 5 prime numbers you have specified. Thus, it becomes impossible to decrypt your password, because the encryption sequence and numbers are kept by you alone.

In your .json file should be kept like this:

{
  "FmgLibCryption": {
    "Chars": "$IJP#FGK%OH@!4S[TU5bc(de>fgC<Dh-tuEv+no/*a_ij}x]L7kly2VW{X36B8w0?;qr9m)ps:AMR=YZ^z1&NQ",
    "Numbers": "4987,11,7907,239,7213"
  }
}

Things to consider in .json format: 1- 'FmgLibCryption', 'Numbers' and 'Chars' key names should be written exactly like this. 2- 'Numbers' must have exactly 5 number values in its value. (In case of missing, the remaining numbers are taken as 0. In case of excess, the numbers written in excess are not taken into account.) 3- You must separate the numbers in the value of the 'Numbers' with the ',' character. 4- You can change the value for the 'Chars' as you wish. Likewise, you can change the values for the 'Numbers' as you wish. (Since these values are used in the encryption method, your encryption will vary depending on the values here.)