This is the example source code for my (in-progress) book, Practical Crypto with Go.
- chapter3: symmetric security
- chapter4: key exchange
- chapter5: digital signatures
You can read the book online.
Example source code for the Practical Crypto with Go book.
Home Page: https://leanpub.com/gocrypto/
License: ISC License
This is the example source code for my (in-progress) book, Practical Crypto with Go.
You can read the book online.
Hello, first of all thanks for a great book! just wondering if you have any example on how to do token based authentication?
Basically the idea is for mobile clients authenticating against a backend API where they send email/pass combination and returns a token which is submitted for future requests.
I wrote a sample implementation, do you see potential problems with it?
In the pkc package in Chapter 7 the Encrypt function looks like this:
func Encrypt(pub *rsa.PublicKey, pt []byte) (ct []byte, err error) {
if len(ct) > MaxMessageLength(pub) {
err = fmt.Errorf("message is too long")
return
}
hash := sha256.New()
ct, err = rsa.EncryptOAEP(hash, rand.Reader, pub, pt, defaultLabel)
return
}
gocrypto/chapter7/pkc/crypto.go
Line 37 in b8e4fbb
The length of ct is verified against MaxMessageLength. Shouldn't the length of pt be checked instead?
func Encrypt(pub *rsa.PublicKey, pt []byte) (ct []byte, err error) {
if len(pt) > MaxMessageLength(pub) {
err = fmt.Errorf("message is too long")
return
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.