From C# encryption key derivation to Ruby (PBKDF2) -
i'm trying rewrite following key generation method written in c# ruby equivalent: private static byte[] createkey(string password, int length) { var salt = new byte[] { 0x01, 0x02, 0x23, 0x34, 0x37, 0x48, 0x24, 0x63, 0x99, 0x04 }; const int iterations = 1000; using (var rfc2898derivebytes = new rfc2898derivebytes(password, salt, iterations)) return rfc2898derivebytes.getbytes(length); } i'm using pbkdf2 implementation. , here's ruby code: def create_key password, length salt_a = [0x01, 0x02, 0x23, 0x34, 0x37, 0x48, 0x24, 0x63, 0x99, 0x04] salt = salt_a.pack('c*') # think here there change iterations = 1000 derived_b = pbkdf2.new |p| p.password = password p.salt = salt p.iterations = iterations p.key_length = length p.hash_function = openssl::digest::sha1 end derived_b.bin_string # , here end in order work 2 methods should r