vinegar

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

README

vinegar

vinegar is a library for producing, Vigenere tables and encrypting/decrypting messages with them.

Plaintext messages have their spaces removed during encryption as the library uses the standard latin alphabet modified by a keyword (with duplicates removed). This means the decrypted message will also have no spaces but will match the plaintext input in all other ways.

package main

import (
    "fmt"
  
    "github.com/h5law/vinegar"
)

func main() {
    vig := vinegar.NewVigenere("kyrptos")
    cipher := vig.Encrypt("this is a secret hidden message", "neddih")
    plain := vig.Decrypt(cipher, "neddih")
    fmt.Println(cipher)                        // wzzjtqklunlzwzzqzzfpujuusv
    fmt.Println(plain)                         // thisisasecrethiddenmessage
    // Using the wrong key
    fmt.Println(vig.Decrypt(cipher, "hidden")) // cdisnyfrecsscdidhsxhesdrma
}

Documentation

Overview

Package vinegar provides a Vigenere table builder and encryption/decryption tools for encoding and decoding plaintext and its corresponding ciphertext.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vigenere

type Vigenere interface {
	// Encrypt encrypts the given message using the keyword provided
	// according to the vigenere table of the Vigenere struct.
	Encrypt(message, keyword string) string
	// Decrypt decrypts the provided ciphertext using the keyword and
	// vigenere table from the struct - the resulting plaintext will have no spaces.
	Decrypt(cipher, keyword string) string
}

func NewVigenere

func NewVigenere(keyword string) Vigenere

NewVigenere produces a Vigenere Table using the given keyword. It first will format the keyword given by removing any duplicates and enforcing it to be 26 lowercasse latin characters. Once formatted the table is produced by shifting the alphabet 26 times maaking a 26x26 matrix of runes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL