I need to convert some old C# code to Golang and I stuck somewhere. C# code looks like this `
byte[] bytes = Encoding.Unicode.GetBytes(password);
byte[] src = Encoding.Unicode.GetBytes(salt);
byte[] dst = new byte[src.Length + bytes.Length];
Buffer.BlockCopy(src, 0, dst, 0, src.Length);
Buffer.BlockCopy(bytes, 0, dst, src.Length, bytes.Length);
HashAlgorithm algorithm = HashAlgorithm.Create("SHA1");
byte[] inArray = algorithm.ComputeHash(dst);
return Convert.ToBase64String(inArray);
so I examined the code line by line and as I understand he used convert the salt and password byte array then he copied these arrays to 'dst' array. Then he used SHA1 algorithm and convert this array to base64string.
My Golang code looks like this but It doesn't create the same string which stores on database.
s := "fish123"
salt := "227EA7ABD26E40608A6EDEB209058D93A632D1D1A52246D0A27F6E447B16AEBF"
h1 := sha1.New()
h1.Write([]byte(salt))
h1.Write([]byte(s))
hashedPassword := base64.StdEncoding.EncodeToString(h1.Sum(nil))
Can anyone find my fault? Thanks