ncipher

package module
v0.0.0-...-b33b795 Latest Latest
Warning

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

Go to latest
Published: May 12, 2017 License: MIT Imports: 5 Imported by: 0

README

ncipher

ncipher provides "Nyanpasu Cipher (N-Cipher)" encoder & decoder

Usage

package main

import (
	"fmt"

	"github.com/844196/ncipher"
)

func main() {
	src := "われわれはかしこいので"
	out := ncipher.StdEncoding.Encode(src)

	fmt.Println(out)
	// Output: ぱすすんゃゃ〜ぱすすんにぱ〜ぱすすんゃゃ〜ぱすすんにぱ〜ぱすすにすす〜ぱすぱすんぱ〜ぱすすににに〜ぱすぱすすゃ〜ぱすぱすゃゃ〜ぱすすにすぱ〜ぱすすにぱゃ〜
}
package main

import (
	"fmt"

	"github.com/844196/ncipher"
)

func main() {
	enc, _ := ncipher.NewEncoding(ncipher.Config{
		Seed:      "あいうえおかきくけこさしすせそたちつてとなにぬねの",
		Delimiter: "、",
	})

	src := "ふーbar ほげfuga"

	encoded := enc.Encode(src)
	fmt.Println(encoded)
	// Output: とにか、ないた、えね、えぬ、おそ、いく、とにし、ととな、おう、おつ、おえ、えぬ、

	decoded, _ := enc.Decode(encoded)
	fmt.Println(decoded)
	// Output: ふーbar ほげfuga
}

Installation

$ go get github.com/844196/ncipher

Documentation

Overview

Package ncipher provides "Nyanpasu Cipher (N-Cipher)" encoder & decoder

Example
package main

import (
	"fmt"

	"github.com/844196/ncipher"
)

func main() {
	in := "われわれはかしこいので"
	out := ncipher.StdEncoding.Encode(in)

	fmt.Println(out)
}
Output:

ぱすすんゃゃ〜ぱすすんにぱ〜ぱすすんゃゃ〜ぱすすんにぱ〜ぱすすにすす〜ぱすぱすんぱ〜ぱすすににに〜ぱすぱすすゃ〜ぱすぱすゃゃ〜ぱすすにすぱ〜ぱすすにぱゃ〜

Index

Examples

Constants

View Source
const (
	SeedMin      = 2
	SeedMax      = 36
	DelimiterMin = 1
)

Variables

View Source
var (
	StdConfig      = Config{Seed: "にゃんぱす", Delimiter: "〜"}
	StdEncoding, _ = NewEncoding(&StdConfig)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Seed, Delimiter string
}

type Encoding

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

func NewEncoding

func NewEncoding(cnf *Config) (*Encoding, error)

func (*Encoding) Decode

func (e *Encoding) Decode(src string) (dst string, err error)
Example
package main

import (
	"fmt"

	"github.com/844196/ncipher"
)

func main() {
	cnf := ncipher.Config{
		Seed:      "あいうえおかきくけこさしすせそたちつてとなにぬねの",
		Delimiter: "、",
	}
	enc, _ := ncipher.NewEncoding(&cnf)

	in := "とにか、ないた、えね、えぬ、おそ、いく、とにし、ととな、おう、おつ、おえ、えぬ、"
	out, _ := enc.Decode(in)

	fmt.Println(out)
}
Output:

ふーbar ほげfuga

func (*Encoding) Encode

func (e *Encoding) Encode(src string) (dst string)
Example
package main

import (
	"fmt"

	"github.com/844196/ncipher"
)

func main() {
	cnf := ncipher.Config{
		Seed:      "あいうえおかきくけこさしすせそたちつてとなにぬねの",
		Delimiter: "、",
	}
	enc, _ := ncipher.NewEncoding(&cnf)

	in := "ふーbar ほげfuga"
	out := enc.Encode(in)

	fmt.Println(out)
}
Output:

とにか、ないた、えね、えぬ、おそ、いく、とにし、ととな、おう、おつ、おえ、えぬ、

Jump to

Keyboard shortcuts

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