Giter Club home page Giter Club logo

fernet-go's Introduction

Fernet takes a user-provided *message* (an arbitrary sequence of
bytes), a *key* (256 bits), and the current time, and produces a
*token*, which contains the message in a form that can't be read
or altered without the key.

This package is compatible with the other implementations at
https://github.com/fernet. They can exchange tokens freely among
each other.

Documentation: http://godoc.org/github.com/fernet/fernet-go


INSTALL

	$ go get github.com/fernet/fernet-go


For more information and background, see the Fernet spec at
https://github.com/fernet/spec.

Fernet is distributed under the terms of the MIT license.
See the License file for details.

fernet-go's People

Contributors

bmizerany avatar chet avatar cyberdelia avatar fishy avatar kennyp avatar kr avatar samdfonseca avatar xd-deng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fernet-go's Issues

Encoded key not equal to its input.

I expected that when I provide a string input s to fernet for decoding, that I can take the resulting key and encode it to be s' and I should find that s' is equal to s.

Here is a sample program that demonstrates that what I expect is not what actually happens:

Fernet Version:

$ cd $GOPATH/src/github.com/kr/fernet
$ git log -1 --pretty=%h
9596341

Go Version:

$ go version
go version go1.1.1 darwin/amd64

Program:

package main

import (
    "fmt"
    "github.com/kr/fernet"
)

func main() {
    s := "BecstsYSkJY33Us91kgl6qPubHowWXcqaBxqhu7Nu6_="
    k := fernet.MustDecodeKeys(s)
    fmt.Printf("s=%s\ns'=%s\n", s, k[0].Encode())
}

Result:

$ go run x.go 
s =BecstsYSkJY33Us91kgl6qPubHowWXcqaBxqhu7Nu6_=
s'=BecstsYSkJY33Us91kgl6qPubHowWXcqaBxqhu7Nu68=

VerifyAndDecrypt panics on malformed input

package main

import (
    "fmt"
    "time"
    "github.com/fernet/fernet-go"
)

func main() {
    a := []byte{103, 71, 70, 105, 89, 119, 61, 61}
    keys := fernet.MustDecodeKeys("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
    fmt.Println(fernet.VerifyAndDecrypt(a, time.Second * 60, keys))
}

Separate keys with same secret fail

This had me pulling hair for a while, but it seems that, if a different key is used to decrypt a token than is used to create it, even if they have the same secret, it will fail. Unfortunately, this means I cannot use fernet across servers.

add test cases for malformed/invalid base64 and version byte

  • add a test against an invalid version (any value othe than 0x80, say 0x00 and 0x81)
  • add a test vector that contains invalid base64 encodings, e.g. whitespace, line endings, missing padding characters, last bits not set to zero, / or + character etc.

Does it make sense to support a binary encoding?

I've noticed that encrypted payloads are base64 coded. Does it make any sense to have a binary mode? I'd like to use Fernet in a high-volume way (maybe that's against design ethos, I am not sure) and avoid paying for base64 in size blowup if possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.