xorcipher

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 2 Imported by: 0

README

xorcipher

Go Reference Go Report Card

xorcipher is a XOR Cipher library for Go.

Basic Usage

package main

import (
    "fmt"
    "encoding/hex"

    "github.com/MatusOllah/xorcipher"
)

func main() {
    key := []byte("horalky")
    plaintext := []byte("Hello, World!")

    block, err := xorcipher.NewCipher(key)
    if err != nil {
        panic(err)
    }

    ciphertext := make([]byte, len(plaintext))
    block.Encrypt(ciphertext, plaintext)

    fmt.Println(hex.EncodeToString(ciphertext)) // > 200a1e0d0347593f00000d084a
}

Documentation

Overview

Package xorcipher implements XOR Cipher.

Index

Constants

View Source
const BlockSize = 1

The XOR Cipher "block size" in bytes.

Variables

This section is empty.

Functions

func NewCipher

func NewCipher(key []byte) (cipher.Block, error)

NewCipher creates and returns a new cipher.Block. It returns an error if the key length is zero.

Types

type KeySizeError

type KeySizeError int

KeySizeError represents an error due to an invalid key size.

func (KeySizeError) Error

func (k KeySizeError) Error() string

Error returns a string representation of the KeySizeError k.

Jump to

Keyboard shortcuts

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