cipherpol

package module
v0.0.0-...-2e8c587 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 13 Imported by: 0

README ΒΆ

CipherPol

CipherPol is a Go package that implements a grid-based cipher utilizing various ancient and unique character sets (runes) for data encryption and decryption. It allows you to encrypt plaintext messages into a grid of custom runes and decrypt them back using a password. The grid size adjusts automatically based on the length of the message, and you can select from multiple character sets to create visually diverse and intriguing encrypted grids.

Features

  • Grid-Based Encryption: Encrypt messages into a grid of runes, creating a unique visual representation.
  • Customizable Character Sets: Choose from various ancient scripts and runes for the grid characters.
  • Automatic Grid Size Adjustment: The grid size adjusts automatically based on the length of the plaintext.
  • Secure Encryption: Utilizes AES-256-GCM encryption with PBKDF2 key derivation for strong security.
  • Deterministic Decryption: The same password and character set are required to decrypt the message successfully.
  • Error Handling: Provides meaningful errors for invalid inputs and decryption failures.

Installation

To use CipherPol in your Go project, you can install it using go get:

go get github.com/donseba/cipherpol

Usage

Here's a simple example of how to encrypt and decrypt a message using CipherPol:

package main

import (
    "fmt"
    "github.com/donseba/cipherpol"
)

func main() {
    // Create a new CipherPol instance with a password and character set
    cp := cipherpol.NewCypher()

	cp.SetCharacterSet(cipherpol.CharacterSetPhoenician)

	password := "SuperSecretPassword"
	
	// Encrypt the message
	err := cp.EncryptWithAutoGridSize("Hello, CipherPol!", password)
	if err != nil {
        fmt.Println("Encryption error:", err)
        return
    }

	// Display the grid
	fmt.Println("Encrypted Grid:")
	fmt.Println(cp.Grid())
	
    fmt.Println("Encrypted message:", cp.Grid())

    // Decrypt the message
    decrypted, err := cp.Decrypt(cp.RawGrid(), password)
    if err != nil {
        fmt.Println("Decryption error:", err)
        return
    }

    fmt.Println("Decrypted message:", decrypted)
}

the encoded grid/message would look like:

π€‰π€†π€π€ˆπ€‚π€‡π€Œπ€‰π€‚π€‚π€“
π€π€…π€Žπ€†π€π€…π€π€π€“π€ˆπ€“
π€‡π€ˆπ€•π€ƒπ€‚π€ƒπ€Šπ€ƒπ€π€“π€‚
π€Žπ€Šπ€•π€π€‹π€Œπ€π€“π€’π€”π€‚
π€π€‹π€“π€Šπ€π€‚π€€π€€π€π€”π€
π€Œπ€ˆπ€Žπ€‹π€†0𐀀𐀓𐀍𐀏𐀐
π€…π€‡π€‹π€€π€ƒπ€Žπ€‚0π€ˆπ€π€’
𐀍0π€‡π€ƒπ€π€€π€π€’π€π€‰π€Š
π€‡π€π€€π€‚π€π€…π€π€ˆπ€1𐀄
𐀋𐀑𐀐1π€Šπ€”π€•π€”π€Žπ€‚π€€
π€‡π€π€“π€π€Žπ€Šπ€Žπ€π€‰π€†π€‡

Character Sets

CipherPol supports a variety of ancient and unique character sets:

  • Ogham (CharacterSetOgham): Early Medieval Irish script.
  • Linear B (CharacterSetLinearB): Ancient Mycenaean Greek script.
  • Egyptian Hieroglyphs (CharacterSetEgyptian): Ancient Egyptian writing system.
  • Glagolitic Script (CharacterSetGlagolitic): Oldest known Slavic alphabet.
  • Coptic Script (CharacterSetCoptic): Used for the Coptic language.
  • Gothic Script (CharacterSetGothic): Used for writing the Gothic language.
  • Phoenician Script (CharacterSetPhoenician): Ancient Semitic script.
  • Ugaritic Script (CharacterSetUgaritic): Used in ancient Ugarit.
  • Viking Runes (CharacterSetViking): Runic alphabets used by Germanic peoples.
  • Hiragana (CharacterSetHiragana): Japanese syllabary.
  • Katakana (CharacterSetKatakana): Japanese syllabary.
  • Mayan Numerals (CharacterSetMayan): Ancient Mayan number system.

If no character set is specified, all available character sets are used by default.

Selecting Character Sets

You can select a character set for the grid using the SetCharacterSet method:

// Set custom character sets
cipher.SetCharacterSet(
    cipherpol.CharacterSetViking,
    cipherpol.CharacterSetHiragana,
    cipherpol.CharacterSetEgyptian,
)

if you don't specify any character set, all available character sets will be used by default.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	ErrorNotEnoughPositions     = errors.New("not enough positions to embed data")
	ErrorDataTooLarge           = errors.New("data too large to fit in the grid")
	ErrorInvalidLength          = errors.New("invalid length")
	ErrorSerializedDataTooShort = errors.New("serialized data too short")
	ErrorInvalidRuneInEncoded   = errors.New("invalid rune in encoded string")
)

Character set for the grid

Functions ΒΆ

This section is empty.

Types ΒΆ

type CharacterSet ΒΆ

type CharacterSet string
const (
	CharacterSetOgham      CharacterSet = "Ogham"
	CharacterSetLinearB    CharacterSet = "Linear B"
	CharacterSetEgyptian   CharacterSet = "Egyptian Hieroglyphs"
	CharacterSetGlagolitic CharacterSet = "Glagolitic Script"
	CharacterSetCoptic     CharacterSet = "Coptic Script"
	CharacterSetGothic     CharacterSet = "Gothic Script"
	CharacterSetPhoenician CharacterSet = "Phoenician Script"
	CharacterSetUgaritic   CharacterSet = "Ugaritic Script"
	CharacterSetViking     CharacterSet = "Viking Runes"
	CharacterSetHiragana   CharacterSet = "Hiragana"
	CharacterSetKatakana   CharacterSet = "Katakana"
	CharacterSetMayan      CharacterSet = "Mayan Numerals"
)

type Cypher ΒΆ

type Cypher struct {
	// contains filtered or unexported fields
}

func NewCypher ΒΆ

func NewCypher() *Cypher

func (*Cypher) Decrypt ΒΆ

func (c *Cypher) Decrypt(grid [][]rune, password string) (string, error)

func (*Cypher) Encrypt ΒΆ

func (c *Cypher) Encrypt(plaintext, password string, gridSize int) error

Encrypt encrypts the plaintext message using the provided password and grid size

func (*Cypher) EncryptWithAutoGridSize ΒΆ

func (c *Cypher) EncryptWithAutoGridSize(plaintext, password string) error

EncryptWithAutoGridSize encrypts the plaintext message using the provided password and automatically adjusts the grid size as needed.

func (*Cypher) Grid ΒΆ

func (c *Cypher) Grid() string

func (*Cypher) GridSize ΒΆ

func (c *Cypher) GridSize() int

func (*Cypher) RawGrid ΒΆ

func (c *Cypher) RawGrid() [][]rune

func (*Cypher) SetCharacterSet ΒΆ

func (c *Cypher) SetCharacterSet(characterSet ...CharacterSet)

type Interface ΒΆ

type Interface interface {
	EncryptWithAutoGridSize(plaintext, password string) error
	Encrypt(plaintext, password string, gridSize int) ([][]rune, error)
	Decrypt(grid [][]rune, password string) (string, error)
	SetCharacterSet(characterSet ...CharacterSet)
	Grid() string
	GridSize() int
	RawGrid() [][]rune
}

Jump to

Keyboard shortcuts

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