Download this file
| 1 | package protocol |
| 2 | |
| 3 | import ( |
| 4 | "crypto/sha256" |
| 5 | "encoding/hex" |
| 6 | "strings" |
| 7 | ) |
| 8 | |
| 9 | // AuthenticationCode lets a person compare the browser's authorization request |
| 10 | // with the one they initiated in their app. It is a label, never a credential. |
| 11 | func AuthenticationCode(id string) string { |
| 12 | sum := sha256.Sum256([]byte(id)) |
| 13 | code := strings.ToUpper(hex.EncodeToString(sum[:4])) |
| 14 | return code[:4] + "-" + code[4:] |
| 15 | } |
| 16 | |