GithubHelp home page GithubHelp logo

moelsayedosman / encryptionalgorithms Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 13 KB

Encryption and decryption

C# 100.00%
caesar-cipher monoalphabetic-cipher playfair-cipher polyalphabetic-cipher c-sharp encryption-decryption

encryptionalgorithms's Introduction

Lib_SC: Encryption and Decryption Library

Lib_SC is a C# library that provides implementations for various encryption and decryption techniques. The library includes classes for Caesar, Monoalphabetic, Playfair, and Polyalphabetic ciphers. Each class offers methods to encrypt and decrypt strings using the respective cipher technique.


Table of Contents


Features

  • Caesar Cipher: Simple shift cipher where each letter in the plaintext is shifted a certain number of places down the alphabet.
  • Monoalphabetic Cipher: Substitution cipher where each letter in the plaintext is replaced by a letter with a fixed relationship.
  • Playfair Cipher: Digraph substitution cipher where plaintext letters are replaced using a 5x5 matrix.
  • Polyalphabetic Cipher: Utilizes multiple Caesar ciphers in sequence with different shifts for each character based on its position.

Classes and Methods

Caesar Cipher

namespace Lib_SC
{
    public class Caesar
    {
        /// <summary>
        /// Encrypts or decrypts a given string using a specified key.
        /// </summary>
        /// <param name="encryption">The string to encrypt or decrypt.</param>
        /// <param name="key">The encryption or decryption key.</param>
        /// <param name="enc">True for encryption, False for decryption.</param>
        /// <returns>The encrypted or decrypted string.</returns>
        public static string MainCaesar(string encryption, int key, bool enc);
    }
}

Monoalphabetic Cipher

namespace Lib_SC
{
    public class Monoalphabetic
    {
        /// <summary>
        /// Encrypts or decrypts a given string using a specified key.
        /// </summary>
        /// <param name="oldText">The string to encrypt or decrypt.</param>
        /// <param name="key">The encryption or decryption key.</param>
        /// <param name="encrypt">True for encryption, False for decryption.</param>
        /// <returns>The encrypted or decrypted string.</returns>
        public static string MainFunctionMonoalphabetic(string oldText, string key, bool encrypt);
    }
}

Playfair Cipher

namespace Lib_SC
{
    public class Playfair
    {
        /// <summary>
        /// Encrypts or decrypts a given string using a specified key and Playfair cipher logic.
        /// </summary>
        /// <param name="text">The string to encrypt or decrypt.</param>
        /// <param name="key">The encryption or decryption key.</param>
        /// <param name="encryptionBool">True for encryption, False for decryption.</param>
        /// <returns>The encrypted or decrypted string.</returns>
        public static string MainPlayfair(string text, string key, bool encryptionBool);
    }
}

Polyalphabetic Cipherr

namespace Lib_SC
{
    public class Polyalphabetic
    {
        /// <summary>
        /// Encrypts or decrypts a given string using a polyalphabetic cipher.
        /// </summary>
        /// <param name="text">The string to encrypt or decrypt.</param>
        /// <param name="encrypt">True for encryption, False for decryption.</param>
        /// <returns>The encrypted or decrypted string.</returns>
        public static string MainPolyalphabetic(string text, bool encrypt);
    }
}

Usage

using Lib_SC;
using System;

class Program
{
    static void Main()
    {
        string plaintext = "HELLO";
        bool encrypt = true;

        // Encrypt using Polyalphabetic cipher
        string encryptedText = Polyalphabetic.MainPolyalphabetic(plaintext, encrypt);
        Console.WriteLine($"Encrypted Text: {encryptedText}");

        // Decrypt using Polyalphabetic cipher
        encrypt = false;
        string decryptedText = Polyalphabetic.MainPolyalphabetic(encryptedText, encrypt);
        Console.WriteLine($"Decrypted Text: {decryptedText}");
    }
}

encryptionalgorithms's People

Contributors

moelsayedosman avatar

Stargazers

Mahmoud Yosri avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.