Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
/.glide
.idea
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove. Developer specific files don't belong here.

Use git config --global core.excludesfile $HOME/.gitignore instead.

Which file to place a pattern in depends on how the pattern is meant to be used.

Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file.

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.

Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.

-- https://git-scm.com/docs/gitignore

6 changes: 6 additions & 0 deletions crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"crypto/ed25519"
"crypto/elliptic"
"crypto/hmac"
"crypto/md5"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
Expand Down Expand Up @@ -73,6 +74,11 @@ func hashSha(password string) string {
return base64.StdEncoding.EncodeToString(passwordSum)
}

func md5sum(input string) string {
hash := md5.Sum([]byte(input))
return hex.EncodeToString(hash[:])
}

// HashAlgorithm enum for hashing algorithms
type HashAlgorithm string

Expand Down
7 changes: 7 additions & 0 deletions crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func TestSha1Sum(t *testing.T) {
}
}

func TestMd5Sum(t *testing.T) {
tpl := `{{"abc" | md5sum}}`
if err := runt(tpl, "900150983cd24fb0d6963f7d28e17f72"); err != nil {
t.Error(err)
}
}

func TestAdler32Sum(t *testing.T) {
tpl := `{{"abc" | adler32sum}}`
if err := runt(tpl, "38600999"); err != nil {
Expand Down
8 changes: 8 additions & 0 deletions docs/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,11 @@ algorithm and returns the decoded text.
```
"30tEfhuJSVRhpG97XCuWgz2okj7L8vQ1s6V9zVUPeDQ=" | decryptAES "secretkey"
```

## md5sum

The `md5sum` function receives a string, and computes it's MD5 digest.

```
md5sum "Hello world!"
```
1 change: 1 addition & 0 deletions functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var genericMap = map[string]interface{}{
"sha256sum": sha256sum,
"sha512sum": sha512sum,
"adler32sum": adler32sum,
"md5sum": md5sum,
"toString": strval,

// Wrap Atoi to stop errors.
Expand Down