*What algorithm using Rfc2898DeriveBytes* On Sunday, October 11, 2015 at 2:36:23 PM UTC+5:30, Skip wrote: > > i'm guessing iteration and/or hash function doesn't match. however, i'm > not an expert; hopefully someone with first hand experience with pbkdf1 > will comment. > > if this is for a real application (rather than an exercise), PBKDF1 > shouldn't be used. C#/.NET supports PBKDF2 (Rfc2898DeriveBytes). > > > On Sat, Oct 10, 2015 at 11:56 PM, tuanhoanganh <hatu...@gmail.com > <javascript:>> wrote: > >> @Skip Tavakkolian >> >> my cursory review of RFC-2898 leads me to believe that pbkdf2.Key() with >>> proper keylen and hash function can produce pbkdf1 keys. >>> >> >> Here is my test pbkdf2 but don't has same result as c# >> >> === crypt.go === >> >> package crypt >> >> >> import ( >> >> "golang.org/x/crypto/pbkdf2" >> >> "crypto/sha1" >> >> ) >> >> >> var strDefaultKey string="65EA7902-C2A0-436E-8345-22260DC104C0"; >> >> var defaultIV = []byte{43, 56, 32, 32, 32, 23, 22, 32} >> >> var salt = []byte{55, 156, 33, 56, 100, 43, 45, 43 } >> >> >> func GetDefaultPass() string { >> >> return strDefaultKey >> >> } >> >> >> func GetDefaultPassByte() []byte { >> >> return []byte(strDefaultKey) >> >> } >> >> >> func GetKey(password string) []byte { >> >> return pbkdf2.Key([]byte(password), salt, 100, 8, sha1.New) >> >> } >> >> >> === crypt_test.go === >> >> package crypt_tests >> >> >> import ( >> >> "erpvietnam/fhc/core" >> >> "testing" >> >> "bytes" >> >> "fmt" >> >> ) >> >> >> func TestGetDefaultPassByte(t *testing.T) { >> >> ok := []byte{54, 53, 69, 65, 55, 57, 48, 50, 45, 67, 50, 65, 48, 45, 52, >> 51, 54, 69, 45, 56, 51, 52, 53, 45, 50, 50, 50, 54, 48, 68, 67, 49, 48, 52, >> 67, 48} >> >> result := crypt.GetDefaultPassByte() >> >> if(!bytes.Equal(ok, result)) { >> >> t.Error("crypt.GetDefaultPassByte failed ok:", ok, "vs result:", >> result) >> >> } >> >> } >> >> >> func TestGetKey(t *testing.T) { >> >> ok := []byte {200, 144, 191, 9, 93, 72, 42, 233} >> >> result := crypt.GetKey(crypt.GetDefaultPass()) >> >> if(!bytes.Equal(ok, result)) { >> >> t.Error("crypt.GetKey failed ok:", ok, "vs result:", result) >> >> } >> >> } >> >> >> >> >
-- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.