Skip to content

Commit d3e1a67

Browse files
committed
Added new kyu
1 parent 1ebb99e commit d3e1a67

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

golang/7_kyu_password_hashes.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
3+
When you sign up for an account somewhere, some websites do not actually store your password in their databases.
4+
Instead, they will transform your password into something else using a cryptographic hashing algorithm.
5+
6+
After the password is transformed, it is then called a password hash.
7+
Whenever you try to login, the website will transform the password you tried using the same hashing algorithm and simply see if the password hashes are the same.
8+
9+
Create the function that converts a given string into an md5 hash. The return value should be encoded in hexadecimal.
10+
11+
*/
12+
13+
package kata
14+
15+
import (
16+
"crypto/md5"
17+
"encoding/hex"
18+
)
19+
20+
func PassHash(str string) string {
21+
hasher := md5.New()
22+
hasher.Write([]byte(str))
23+
24+
return hex.EncodeToString(hasher.Sum(nil))
25+
}

0 commit comments

Comments
 (0)