Skip to content
Snippets Groups Projects
Commit 47b7398a authored by Rohith Jayawardene's avatar Rohith Jayawardene Committed by Rohith
Browse files

Base64 Encoding (#226)

- reverting back to the base64 encoding due to header size considerations
parent 0ad1a3e6
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ import ( ...@@ -22,7 +22,7 @@ import (
"crypto/rand" "crypto/rand"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"encoding/hex" "encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
...@@ -126,12 +126,12 @@ func encodeText(plaintext string, key string) (string, error) { ...@@ -126,12 +126,12 @@ func encodeText(plaintext string, key string) (string, error) {
return "", err return "", err
} }
return hex.EncodeToString(cipherText), nil return base64.RawStdEncoding.EncodeToString(cipherText), nil
} }
// decodeText decodes the session state cookie value // decodeText decodes the session state cookie value
func decodeText(state, key string) (string, error) { func decodeText(state, key string) (string, error) {
cipherText, err := hex.DecodeString(state) cipherText, err := base64.RawStdEncoding.DecodeString(state)
if err != nil { if err != nil {
return "", err return "", err
} }
...@@ -434,7 +434,7 @@ func getWithin(expires time.Time, within float64) time.Duration { ...@@ -434,7 +434,7 @@ func getWithin(expires time.Time, within float64) time.Duration {
// getHashKey returns a hash of the encodes jwt token // getHashKey returns a hash of the encodes jwt token
func getHashKey(token *jose.JWT) string { func getHashKey(token *jose.JWT) string {
hash := md5.Sum([]byte(token.Encode())) hash := md5.Sum([]byte(token.Encode()))
return hex.EncodeToString(hash[:]) return base64.RawStdEncoding.EncodeToString(hash[:])
} }
// printError display the command line usage and error // printError display the command line usage and error
......
...@@ -135,7 +135,7 @@ var ( ...@@ -135,7 +135,7 @@ var (
JxkaNpboZ6hnrMytlw5kf0biF7dLTU885uHIGkUIRy75hx6BaTEEhbN36qVTxediEHd6xeBPS3qpJ7riO6J JxkaNpboZ6hnrMytlw5kf0biF7dLTU885uHIGkUIRy75hx6BaTEEhbN36qVTxediEHd6xeBPS3qpJ7riO6J
EeaQr1rroDL0LvmDyB6Zds4LdVQEmtUueusc7jkBz7gJ12vnTHIxviZM5rzcq4tyCbZO7Kb37RqZg5kbYGK EeaQr1rroDL0LvmDyB6Zds4LdVQEmtUueusc7jkBz7gJ12vnTHIxviZM5rzcq4tyCbZO7Kb37RqZg5kbYGK
PfErhUwUIin7jsNVE7coB`) PfErhUwUIin7jsNVE7coB`)
fakeCipherText = []byte("149e576b52d64bea996e161e4ad0079a95923ee945e93bfe29a5dd3ced347b3c14ea0d58c0d02a5d503cf36cdbf959af4d04e654c8d46c4367903c785867097ea08185602544c6daac59fd8a8a44d83afecc71a1d4ead199bb64bd276f24552c9001fc76113d4ed9838eba6728e0b0e31444a47157d02f40a9ae708ad2f10c271454dcedbecc1455357826962115e88c8230a44bd81d264a3e6e1cf7d0221faa2076f934c1e26f50e6edfbb3c16bc51f826d53cc01e40a755c546df918714cef9743d4ff6355937ee1214eef7925dc204165feb1ee0a926294bf91ed2c54a6ac4764d68b332896bc70379b69029a22966ee0e535a496c4f8eef8399ad4f7011a1b98cd45deed134d791185e5b9f2dccfbd14da3eb618bef4dba52590e96ceb3e9e39") fakeCipherText = []byte("lfQPTa6jwMTABaJhcrfVkoqcdyMVAettMsqgKXIALSKG5UpoYKbT/WgZjOiuCmEI0E/7piP8VATLOAHKDBNF2WrQOKSYF+gdHkh4NLv0cW0NZ2qyZeWhknywE6063ylhCYjJOrJA1z12i2bHHbjZZGfqkwfzyxxFLTv6jSbalpZ4oZcUcNY/DrtVk/K01qZw6o4l1f0FUL6UZVSirn+B3YDWLeVQ0FGr6jlhCpN203Rf688nqdBvhw4bUEQiykCMxWm2/rJBNWm2SzZgw65kb4W0ph1qjcoUjXBwNakK+E0Lw/fwi8+bUC1lkT8+hJpMLKZkzb07rbGAnmljQo0NkqJh4kl+aycsEhm9bZj+b6w0r795YugyNsyca5CnUvkB1Dg")
fakeKey = []byte("u3K0eKsmGl76jY1buzexwYoRRLLQrQck") fakeKey = []byte("u3K0eKsmGl76jY1buzexwYoRRLLQrQck")
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment