caesardisk

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------

----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------

----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------

----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------

----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------

----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * A Caesar Disk maker. *-----------------------------------------------------------------

Index

Constants

View Source
const (
	// Keep this in mind if you want an dual letter & symbol
	// disks that you can use with the same encoding key
	// (same length for both alphabets)
	// 0        1         2         3
	// 1234567890123456789012345678901
	// -------------------------------
	// ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ
	// !"#$%&'()*+,-./ 0123456789:;<=>?
	Alpha_EN string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Alpha_ES string = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ"
	Alpha_CZ string = "ABCČDĎEFGHIJKLMNŇOPQRŘSŠTŤUVWXYÝZŽÁÉÍÓÚĚŮ"
	Alpha_DE string = "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜẞ"
	Alpha_IT string = "ABCDEFGHILMNOPQRSTUVZÉÓÀÈÌÒÙ"
	Alpha_PT string = "ABCÇDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚÀÂÊÔÃÕ"
	Alpha_GR string = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"
	Alpha_RU string = "АБВГДЕËЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"
	Alpha_PU string = `!"#$%&'()*+,-./ 0123456789:;<=>?`

	Alpha_RUNES string = "ᚫᛒᚳᛞᛖᚠᚷᚻᛁᛃᛱᛚᛗᚾᚩᛈᛩᚱᛋᛏᚢᚡᚹᛪᛦᛎ"

	Alpha_ES_DUAL    = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZ"
	Alpha_PU_DUAL_ES = `!"#$%&()*+,-./ 0123456789=?` // to match length of ES_DUAL
	Alpha_PU_DUAL_EN = `!"#$%&()*+,-./ 0123456789?`  // to match length of EN
)
View Source
const (
	DEFAULT_FONT_REGULAR = "ubuntu.regular.ttf"
	DEFAULT_FONT_BOLD    = "ubuntu.bold.ttf"

	FONT_XIROD_REGULAR        = "xirod.regular.ttf"
	FONT_TOXIGENESIS_BOLD     = "toxigenesis.rg-bold.ttf"
	FONT_BREAMCATCHER_REGULAR = "breamcatcher.regular.ttf"
)
View Source
const (
	MANUAL_VERSION string = "1.5.0" // in case vcsVersion not injected during link phase

	// Useful Unicode Characters
	CHR_COPYRIGHT       = '\u00a9'      // ©
	CHR_REGISTERED      = '\u00ae'      // ®
	CHR_GUILLEMET_L     = '\u00ab'      // «
	CHR_GUILLEMET_R     = '\u00bb'      // »
	CHR_TRADEMARK       = '\u2122'      // ™
	CHR_SAMARITAN       = '\u214f'      // ⅏
	CHR_PLACEOFINTEREST = '\u2318'      // ⌘
	CHR_HIGHVOLTAGE     = '\u26a1'      // ⚡
	CHR_TRIDENT         = rune(0x1f531) // 🔱
	CHR_SPLATTER        = rune(0x1fadf)
	CHR_WARNING         = '\u26a0' // ⚠
	CHR_EXCLAMATION     = '\u2757'
	CHR_SKULL           = '\u2620' // ☠

	CO1 = "odlamirG omidiD 5202)C("
	CO2 = "stpircS fO droL 5202)C("
	CO3 = "gnitirwnitsol"

	// Change these values accordingly
	NAME string = "Go Caesar Disk Maker"
	DESC string = "An extended Caesar Cipher for modern-day alphabets"
)

---------------------------------------------------------------- * G l o b a l s *-----------------------------------------------------------------

View Source
const (
	SubTitle string = "C a e s a r  D i s k"
)

Variables

View Source
var (
	ErrCharacterNotFound        error = errors.New("character not found in alphabet")
	ErrCharacterIndexOutOfRange error = errors.New("character index greater than alphabet")
)
View Source
var (

	// DO NOT CHANGE THESE!
	Version      string = appVersion.String()
	ShortVersion string = appVersion.Version()
)
View Source
var DefaultCaesarWheelOptions = CaesarWheelOptions{
	Title:           "",
	Size:            image.Rect(0, 0, 800, 800),
	Radius:          360.0,
	Orthogonal:      true,
	RadialsColor:    NewRGB[uint8](0xd3, 0xd3, 0xd3),
	LettersFontPath: DEFAULT_FONT_BOLD,
	LettersSize:     30.0,
	LetterColor:     NewRGB[uint8](0, 0, 0),
	LetterColorAlt:  NewRGB[uint8](0, 0, 0),
	DigitsFontPath:  DEFAULT_FONT_REGULAR,
	DigitsSize:      18.0,
	DigitsColor:     NewRGB[uint8](0x00, 0x00, 0xff),
}

Default rendering options for the Caesar Wheel

View Source
var (
	ErrUnmatchedDual error = errors.New("for dual alphabet mode both alphabets must have equal lengths")
)
View Source
var Gray = NewRGBA[uint8](0xd3, 0xd3, 0xd3, 0xFF)
View Source
var MidGray = NewRGBA[uint8](0x66, 0x6a, 0x6d, 0xFF)
View Source
var Yellow = NewRGBA[uint8](0xff, 0xfd, 0x01, 0xFF)

Functions

func BuildMeta

func BuildMeta() string

func BuyMeCoffee

func BuyMeCoffee(coffee4 ...string)

Hey! My time costs money too!

func Copyright(owner string, withLogo bool)

func GenerateCaesarWheel

func GenerateCaesarWheel(letters string, filename string, inner bool, opts CaesarWheelOptions) error

Generates a single-alphabet Caesar wheel (inner OR outer) and saves it to a file.

func GenerateCaesarWheelImage

func GenerateCaesarWheelImage(letters string, inner bool, opts CaesarWheelOptions) (image.Image, error)

Generates a single-alphabet Caesar wheel (inner OR outer) and returns the image object.

func GenerateDualCaesarWheel

func GenerateDualCaesarWheel(letters, symbols string, filename string, inner bool, opts CaesarWheelOptions) error

func GoVersion

func GoVersion() string

get the current GO language version

func GoVersionMin

func GoVersionMin(min string) (string, bool)

retrieve the current GO language version and compare it to the minimum required. It returns the current version and whether the condition current >= min is fulfilled or not.

func Height2Points added in v1.3.2

func Height2Points(size float64) float64

Converts the GG size to Points font unit

func IdentifyAlphabet added in v1.3.2

func IdentifyAlphabet(α *AlphabetModel) string

compare the alphabet contents with the predefined list. If found, set its Name and return that name.

func IsBuiltInFont added in v1.3.2

func IsBuiltInFont(fontName string) ([]byte, bool)

check if fontName represents an embedded built-in font. If so, it would return the font data and true. The font data can be fed to LoadEmbeddedFontFaceFromData

func LoadEmbeddedFontFace added in v1.3.2

func LoadEmbeddedFontFace(fS fs.FS, path string, points float64) (font.Face, error)

LoadFontFace is a helper function to load the specified font file with the specified point size. Note that the returned `font.Face` objects are not thread safe and cannot be used in parallel across goroutines. You can usually just use the Context.LoadFontFace function instead of this package-level function. The size is in Points, to use gg units apply Height2Points()

func LoadEmbeddedFontFaceFromData added in v1.3.2

func LoadEmbeddedFontFaceFromData(fontData []byte, size float64) (font.Face, error)
func Logo() string

Funny LordOfScripts logo

func Points2Height added in v1.3.2

func Points2Height(points float64) float64

Converts a size in Points to the standard (Pixels?) used by gg

func Reverse

func Reverse(s string) string

func RuneString

func RuneString(latin string) string

func SuperimposeDisksByShift

func SuperimposeDisksByShift(shift, n int, outerFilename, innerFilename, outputFilename string, isDual bool, opts CaesarWheelOptions) error

Superimpose two disks from a file into another saved to a file.

func SuperimposeDisksByShiftImage

func SuperimposeDisksByShiftImage(shift, n int, outerImg, innerImg image.Image, isDual bool, opts CaesarWheelOptions) (image.Image, error)

Superimpose two disks from image objects and create a composite image.

Types

type AlphabetModel

type AlphabetModel struct {
	Name string
	// contains filtered or unexported fields
}

func AlphabetFactory added in v1.3.2

func AlphabetFactory(nameOrCode string) *AlphabetModel

The AlphabetFactory function returns an instance of the requested alphabet. The nameOrCode can be the full name or its 2-5 letter id. It is case-sensitive. Returns nil if it cannot comply. It sets the Name if it is empty.

func NewAlphabetModel

func NewAlphabetModel(alphabet string) *AlphabetModel

(ctor) alphabet model without case conversion

func NewAlphabetModelCased

func NewAlphabetModelCased(alphabet string) *AlphabetModel

(ctor) an instance of an alphabet made of the given string. It assumes all characters are unique and no trimming is done! However, the alphabet is converted to uppercase.

func NewAlphabetModelForSymbols

func NewAlphabetModelForSymbols(alphabet string) *AlphabetModel

(ctor) A symbols/punctuation-only alphabet without letters that can be upper/lowercased.

func (*AlphabetModel) Character

func (a *AlphabetModel) Character(index int) (rune, error)

return the character at the given zero-based index

func (*AlphabetModel) Find

func (a *AlphabetModel) Find(char rune) int

finds the index of the character (case-insensitive search), or -1 if not present.

func (*AlphabetModel) FindExact

func (a *AlphabetModel) FindExact(char rune) int

finds the index of the exact character (case-sensitive). return -1 if not found

func (*AlphabetModel) FirstChar

func (a *AlphabetModel) FirstChar() rune

func (*AlphabetModel) IsLower

func (a *AlphabetModel) IsLower() bool

func (*AlphabetModel) IsMultiByte

func (a *AlphabetModel) IsMultiByte() bool

whether the alphabet has multi-byte characters

func (*AlphabetModel) IsUpper

func (a *AlphabetModel) IsUpper() bool

func (*AlphabetModel) Length

func (a *AlphabetModel) Length() int

the length or size of the alphabet in Unicode runes (not bytes)

func (*AlphabetModel) String

func (a *AlphabetModel) String() string

implements fmt.Stringer and returns the alphabet string

type CaesarWheelOptions

type CaesarWheelOptions struct {
	Title           string
	Size            image.Rectangle
	Radius          float64
	Orthogonal      bool
	RadialsColor    RGB[uint8]
	LettersFontPath string
	LettersSize     float64
	LetterColor     RGB[uint8]
	LetterColorAlt  RGB[uint8]
	DigitsFontPath  string
	DigitsSize      float64
	DigitsColor     RGB[uint8]
}

Rendering options for a Caesar encoder/decoder wheel

func (*CaesarWheelOptions) SetDigitColor

func (w *CaesarWheelOptions) SetDigitColor(colorHex string) *CaesarWheelOptions

func (*CaesarWheelOptions) SetDigitFont

func (w *CaesarWheelOptions) SetDigitFont(path string, size float64) *CaesarWheelOptions

set font path and size for digits (Caesar key shift)

func (*CaesarWheelOptions) SetLetterColors

func (w *CaesarWheelOptions) SetLetterColors(outer, inner string) *CaesarWheelOptions

func (*CaesarWheelOptions) SetLetterFont

func (w *CaesarWheelOptions) SetLetterFont(path string, size float64) *CaesarWheelOptions

set font path and size for letters (alphabets)

func (*CaesarWheelOptions) String

func (w *CaesarWheelOptions) String() string

implements fmt.Stringer for the CaesarWheelOptions

type RGB

type RGB[T float64 | uint8] struct {
	Red   T
	Green T
	Blue  T
	Alpha T
}

a custom RGBA implementation for the Caesar Wheel

func NewRGB

func NewRGB[T float64 | uint8](r, g, b T) RGB[T]

RGB with maximum alpha (no opacity)

func NewRGBA

func NewRGBA[T float64 | uint8](r, g, b, a T) RGB[T]

RGB with specified alpha

func NewRGBFromString

func NewRGBFromString(colorHex string) RGB[uint8]

func ParseHexColor

func ParseHexColor(s string) (c RGB[uint8], err error)

Parses a string that describes a color in Hex format. using one or two digits for each RGB part. The string must start with a # and no alpha part. Examples: #a5d or #ab24ef

func (RGB[T]) String

func (r RGB[T]) String() string

implements fmt.Stringer

func (RGB[T]) ToColor

func (r RGB[T]) ToColor() color.Color

convert to a Go color from the standard library

func (RGB[T]) ToHexColor

func (r RGB[T]) ToHexColor() string

type TriState

type TriState uint8

a tri-state value (yes, no, maybe)

const (
	No TriState = iota
	Yes
	Unknown
)

Directories

Path Synopsis
cmd
disk command
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------
gui-app command
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------
gui-app/gui
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Here we define a Caesar parameter storage that is directly bound * via data bindings to their respective control widgets in an IGadget.
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Here we define a Caesar parameter storage that is directly bound * via data bindings to their respective control widgets in an IGadget.
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * APP_NAME * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * *-----------------------------------------------------------------
internal
cipher
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk GUI * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Implements basic Caesar cipher encoding/decoding using Unicode * (foreign) alphabets (not just ASCII).
----------------------------------------------------------------- * L o r d O f S c r i p t s (tm) * Copyright (C)2025 Dídimo Grimaldo T. * goCaesarDisk GUI * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Implements basic Caesar cipher encoding/decoding using Unicode * (foreign) alphabets (not just ASCII).
hash
----------------------------------------------------------------- * P u b l i c D o m a i n * Copyleft * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * An XXHash64 implementation.
----------------------------------------------------------------- * P u b l i c D o m a i n * Copyleft * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * An XXHash64 implementation.

Jump to

Keyboard shortcuts

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