Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

enricofoltran/signing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WARNING! This repo is a work in progress, things may be broken, api will change, tests and documentation are missing.

Signing

Utility for creating and restoring url-safe signed JSON objects.

Based on Django's signing.py utility.

Documentation

Read the documentation at godoc.org.

Usage

func ExampleNewSigner() {
	var key string = "v5kyWAnOBiEKVpAZmMC03BY18Fi6u1ALuZZUb0gnU7Q="
	var salt string = "Gm8uSwfozUKXXatEJLpBB1cNq0F0AR1U7LRaqeO Tn8="
	var sep string = ":"

	signer, err := signing.NewSigner(key, sep, salt)
	if err != nil {
		panic(err)
	}

	signed := signer.Sign("the-quick-brown-fox")
	fmt.Print(signed)

	unsigned, err := signer.Unsign(signed)
	switch err {
	case signing.ErrBadSignature:
		fmt.Printf("Unsign error: %v", err)
	default:
		panic(err)
	}
	fmt.Print(unsigned)

	// Output:
	// the-quick-brown-fox:-maTzDzCZGpiiLqm6SZr0KkMfBo
}

Releases

No releases published

Packages

No packages published

Languages