vendredi 31 août 2018

RNGCryptoServiceProvider random string. always returns a string that ends with '='

static public string GetRandomSalt(int saltLength)
    {
        byte[] saltByte = new byte[saltLength];

        using (var random = new RNGCryptoServiceProvider())
        {

            random.GetBytes(saltByte);
        }
        return Convert.ToBase64String(saltByte);
    }

so if the salt length is 8, it will returns some random string but ends with '=', how do I avoid it? looked at other stack overflow solution, but still cannot fix it




Aucun commentaire:

Enregistrer un commentaire