Skip to content

Commit

Permalink
Merge pull request #268 from elisasre/fixxraw
Browse files Browse the repository at this point in the history
fallback to raw encoding
  • Loading branch information
zetaab authored Apr 10, 2024
2 parents 13f2a27 + ff5c704 commit 95c9e9f
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@ import (
"time"
)

// Base64Rawdecode decodes base64 input to string.
func Base64Rawdecode(v string) (string, error) {
data, err := base64.RawStdEncoding.DecodeString(v)
if err != nil {
return "", fmt.Errorf("base64 decode failed: %w", err)
}
return string(data), nil
}

// Base64decode decodes base64 input to string.
func Base64decode(v string) (string, error) {
data, err := base64.StdEncoding.DecodeString(v)
if err != nil {
return "", fmt.Errorf("base64 decode failed: %w", err)
data, err = base64.RawStdEncoding.DecodeString(v)
if err != nil {
return "", fmt.Errorf("base64 decode failed: %w", err)
}
}
return string(data), nil
}
Expand Down

0 comments on commit 95c9e9f

Please sign in to comment.