pigpen_cipher

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

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 8 Imported by: 0

README

猪圈密码

一、猪圈密码介绍

猪圈密码共济会密码解密,朱高密码解密,PigPen_chiper密码,是一种替换密码,加密时将英文字母替换为图形,解密时再根据图形替换回英文字母,并且输入只支持英文字母。

猪圈密码的对应表:

x

二、安装

go get -u github.com/cryptography-research-lab/go-pigpen-cipher

三、API使用示例

目标只支持了把字母加密为猪圈密码的图片,暂不支持从猪圈密码的图片识别回字母:

package main

import (
	"fmt"
	pigpen_cipher "github.com/cryptography-research-lab/go-pigpen-cipher"
	"os"
)

func main() {

	// 把明文加密为图片
	imageBytes, err := pigpen_cipher.Encrypt("helloworld", pigpen_cipher.NewOptions().WithFontSize(80))
	if err != nil {
		fmt.Println("加密失败: " + err.Error())
		return
	}

	// 把图片保存到本地查看
	err = os.WriteFile("test.jpg", imageBytes, os.ModePerm)
	if err != nil {
		fmt.Println("图片保存失败: " + err.Error())
		return
	}
	fmt.Println("图片保存成功!")

}

四、TODO

增加解密,对猪圈密码图片的识别。

字体文件来自: http://www.metools.info/code/c89.html,感谢站长!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPlaintextMustIsLetters = errors.New("plaintext must is letters")

ErrPlaintextMustIsLetters 要加密的明文必须都是英文字母

Functions

func Decrypt

func Decrypt()

Decrypt 对猪圈密码解密 TODO 待实现,还没想好咋实现图形识别

func Encrypt

func Encrypt(plaintext string, options ...*Option) ([]byte, error)

Encrypt 对字符加密,返回加密后的图片

func F

func F()

func GetCharacterContext

func GetCharacterContext() (*freetype.Context, error)

GetCharacterContext 读取字体文件

Types

type Option

type Option struct {

	// 每个字体有多大
	FontSize int

	// 多少列一换行
	ColumnsWidth int
}

Option 加密时的各种选项

func NewOptions

func NewOptions() *Option

func (*Option) WithColumnsWidth

func (x *Option) WithColumnsWidth(columnsWidth int) *Option

func (*Option) WithFontSize

func (x *Option) WithFontSize(fontSize int) *Option

type Table

type Table []rune
var DefaultTable Table = []rune{}

草,怎么表示这些图形啊...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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