I am trying to find the equivalent of the following C# code in Go.
pwd = "abc123";
encoding = Encoding.UTF8;
SHA1 sha1 = SHA1.Create();
byte hash = sha1.ComputeHash(encoding.GetBytes(text));
pwd := "abc123"
hasher := sha1.New() // SHA1.Create();
hasher.Write(byte(pwd)) // sha1.ComputeHash but without encoding in UTF8 ?
According to the documentation:
A string literal, absent byte-level escapes, always holds valid UTF-8 sequences.
So you don't need to encode into utf8 the string if is inside the Golang source code. However, if the string comes from an input, the utf8 package is your friend.