Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 1.11 KB

README.md

File metadata and controls

56 lines (37 loc) · 1.11 KB

go-object-encrypter

build status

Implementation of node js library object encrypter on golang

Install

go get github.com/Gunga-D/object-encrypter

API

The same as ORIGINAL.

Encrypter

The Encrypter is interface of node js object encrypter(secret, options)

Create an instance of encrypter by constructor NewEncrypter(passphrase string) Encrypter. The passphrase could be string.

Important: passphrase not limited by length.

.Decrypt(rawText, obj, encoding)

Decrypt returns the encoding of obj like json Unmarshal method.

rawText is encoded utf-8 text that will be parsed to the struct obj.

encoding is binary method to parse the input rawText.

Example

package main

import (
	oe "github.com/Gunga-D/object-encrypter"	
)

type User struct {
	Name string `json:"name"`
}

func main() {
	ins := oe.NewEncrypter("123467")
	var u User
	err := ins.Decrypt("67384", &u, nil)
	if err != nil {
		panic(err)
	}
}

(c) 2023 Gunga Dondokov