PBKDF2 in Bouncy Castle C#

前端 未结 2 1265
太阳男子
太阳男子 2020-12-05 19:35

I\'ve being messing around the C# Bouncy Castle API to find how to do a PBKDF2 key derivation.

I am really clueless right now.

I tried reading through the Pk

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 20:30

    I just had this problem myself, and found a more direct approach. As of at least Bouncy Castle 1.7 you can do it like this (in VB using Org.BouncyCastle.Crypto):

    Dim bcKeyDer As New Generators.Pkcs5S2ParametersGenerator()
    bcKeyDer.Init(password, salt, keyIterations)
    Dim bcparam As Parameters.KeyParameter = bcKeyDer.GenerateDerivedParameters("aes256", 256)
    Dim key1() As Byte = bcparam.GetKey()
    

    I have tested this against .Net's System.Security.Cryptography, and it works!

提交回复
热议问题