Rabbitio - Rabbit stream cipher package RFC 4503 for Go

rabbitio

rabbitio is a rabbit stream cipher packge based on RFC 4503 for golang
rabbit is a super-fast lightweight stream cipher which uses a 128-bit key and a 64-bit initialization vector, this cipher was designed in 2003 and released in 2008

this is a mirror repository, rabbitio also lives on snix.ir public git service

usage and docs

simple encrypt/decrypting plain text and cipher text with rabbitio
key must be exactly 16 byte len, iv is optional but must be either zero (for nothing) or 8 byte len
you can replace "snix.ir/rabbitio" with "github.com/sina-ghaderi/rabbitio" to use github mirror repository

package main
import (
  "encoding/hex"
  "fmt"
  
  "snix.ir/rabbitio"
)


func main() {
    key := []byte("key-gen-rabbitio")
    ivx := []byte("abcd8795")
    ptx := "plain text -- dummy text to encrypt and decrypt with rabbit"
    str, err := rabbitio.NewCipher(key, ivx)
    if err != nil { panic(err) }
  
    cpt := make([]byte, len(ptx))
    str.XORKeyStream(cpt, []byte(ptx))
    fmt.Println("cipher text ---:", hex.EncodeToString(cpt))
  
    str, err = rabbitio.NewCipher(key, ivx)
    if err != nil { panic(err) }
  
    // decrypt cipher text and print orginal text
    plx := make([]byte, len(cpt))
    str.XORKeyStream(plx, cpt)
    fmt.Println("plain text ----:", string(plx))
}

io interfaces, reader and writer methods: working with writer

package main
import (
	"bytes"
	"encoding/hex"
	"fmt"
	"io"
	"strings"

	"snix.ir/rabbitio"
)

func main() {
	key, ivt := []byte("12345678abcdefgh"), []byte("1234qwer")
	txt := "dummy text to test NewWriterCipher"
	twr := strings.NewReader(txt)
	iw := new(bytes.Buffer)
	cw, err := rabbitio.NewWriterCipher(key, ivt, iw)
	if err != nil {
		panic(err)
	}
	if _, err := io.Copy(cw, twr); err != nil {
		panic(err)
	}
	fmt.Println("cipher-text:", hex.EncodeToString(iw.Bytes()))
	fmt.Println("decrypting cipher text ---")
	ir := new(bytes.Buffer)
	cr, err := rabbitio.NewWriterCipher(key, ivt, ir)
	if err != nil {
		panic(err)
	}
	if _, err := io.Copy(cr, iw); err != nil {
		panic(err)
	}
	fmt.Println(ir.String())
}

io interfaces, reader and writer methods: working with reader

package main
import (
	"bytes"
	"encoding/hex"
	"fmt"
	"io"
	"strings"

	"snix.ir/rabbitio"
)

func main() {
	key, ivt := []byte("12345678abcdefgh"), []byte("1234qwer")
	txt := "test NewReadercipher text dummy tx"
	twr := strings.NewReader(txt)
	iw := new(bytes.Buffer)
	cw, err := rabbitio.NewReaderCipher(key, ivt, twr)
	if err != nil {
		panic(err)
	}
	if _, err := io.Copy(iw, cw); err != nil {
		panic(err)
	}
	fmt.Println("cipher-text:", hex.EncodeToString(iw.Bytes()))
	fmt.Println("decrypting cipher text ---")
	ir := new(bytes.Buffer)
	cr, err := rabbitio.NewReaderCipher(key, ivt, iw)
	if err != nil {
		panic(err)
	}
	if _, err := io.Copy(ir, cr); err != nil {
		panic(err)
	}
	fmt.Println(ir.String())
}

test and benchmarking

unit test and benchmarking provided too, run go test -v or go test -bench=. -benchmem on project root directory

feel free to email me [email protected] if you want to contribute to this project

Copyright 2022 SNIX LLC [email protected] This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Owner
Sina Ghaderi
Chain Smoker, also a creepy guy [email protected]
Sina Ghaderi
Similar Resources

A library to simplify writing applications using TCP sockets to stream protobuff messages

BuffStreams Streaming Protocol Buffers messages over TCP in Golang What is BuffStreams? BuffStreams is a set of abstraction over TCPConns for streamin

Dec 13, 2022

A toy project to stream from a Remarkable2

goMarkableStream I use this toy project to stream my remarkable 2 (firmware 2.5) on my laptop using the local wifi. video/demo here Quick start You ne

Dec 31, 2022

A lightweight stream processing library for Go

A lightweight stream processing library for Go

go-streams A lightweight stream processing library for Go. go-streams provides a simple and concise DSL to build data pipelines. Wiki In computing, a

Dec 31, 2022

V3IO Frames ("Frames") is a Golang based remote data frames access (over gRPC or HTTP stream)

V3IO Frames ("Frames") is a multi-model open-source data-access library that provides a unified high-performance DataFrame API for working with different types of data sources (backends). The library was developed by Iguazio to simplify working with data in the Iguazio Data Science Platform ("the platform"), but it can be extended to support additional backend types.

Oct 1, 2022

Stream Camera based on TCP

Stream Camera based on TCP

streamera Term Project of Computer Networking streamera is a Stream Camera based on TCP, which contains client mode and server mode. Features Client M

Nov 11, 2022

Stream processing stuff for Go

GoStream Type safe Stream processing library inspired in the Java Streams API. Table of contents Requirements Usage examples Limitations Performance C

Dec 26, 2022

Reflex stream client for redis streams

rredis A reflex stream client for a redis streams using the radix client implementation. It provides an API for inserting data into a stream and for c

Oct 5, 2021

Totem - A Go library that can turn a single gRPC stream into bidirectional unary gRPC servers

Totem is a Go library that can turn a single gRPC stream into bidirectional unar

Jan 6, 2023

A simple Go server that broadcasts any data/stream

broadcast A simple Go server that broadcasts any data/stream usage data You can POST data. curl -X POST --data-binary "@111.png" localhost:9222/test.p

Aug 12, 2022
Related tags
An example of a Feistel cipher in Go.

Feistel cipher Background Feistel ciphers are a method for building a [[symmetric key]] [[block cipher]]. Most modern symmetric block ciphers are base

Jan 7, 2022
An implementation of the Information Concealment Engine cipher in Go
An implementation of the Information Concealment Engine cipher in Go

An implementation of the Information Concealment Engine cipher in Go

Jan 26, 2022
Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed.

arp Package arp implements the ARP protocol, as described in RFC 826. MIT Licensed. Portions of this code are taken from the Go standard library. The

Dec 20, 2022
Package dhcp6 implements a DHCPv6 server, as described in RFC 3315. MIT Licensed.

dhcp6 Package dhcp6 implements a DHCPv6 server, as described in IETF RFC 3315. MIT Licensed. At this time, the API is not stable, and may change over

Sep 27, 2022
CoAP Client/Server implementing RFC 7252 for the Go Language

Canopus Canopus is a client/server implementation of the Constrained Application Protocol (CoAP) Updates 25.11.2016 I've added basic dTLS Support base

Nov 18, 2022
Fast RFC 5389 STUN implementation in go

STUN Package stun implements Session Traversal Utilities for NAT (STUN) [RFC5389] protocol and client with no external dependencies and zero allocatio

Nov 28, 2022
Diameter stack and Base Protocol (RFC 6733) for the Go programming language

Diameter Base Protocol Package go-diameter is an implementation of the Diameter Base Protocol RFC 6733 and a stack for the Go programming language. St

Dec 28, 2022
URI Templates (RFC 6570) implemented in Go

uritemplates -- import "github.com/jtacoma/uritemplates" Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf

Jan 15, 2022
Fast RFC 5389 STUN implementation in go

STUN Package stun implements Session Traversal Utilities for NAT (STUN) [RFC5389] protocol and client with no external dependencies and zero allocatio

Jan 1, 2023
RFC 1413 compliant fake identd

RFC 1413 compliant fake identd. It is an implementation of the Ident Protocol, but it lies to the clients and always returns fake identities of queried users.

Oct 29, 2022