Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Base64String generated result with incorrect size

$
0
0

I use Rfc2898DeriveBytes to hash password for asp.net login

        public void HashPassword(string password, string salt = null)
        {
            byte[] saltB = (salt == null) ? GenSalt() : Convert.FromBase64String(salt);
            if (salt == null) salt = Convert.ToBase64String(saltB);

            // test // salt.length is 172
        }

        internal byte[] GenSalt()
        {
            RNGCryptoServiceProvider p = new RNGCryptoServiceProvider();

            byte[] b = new byte[128];
            p.GetBytes(b);
            return b;
        }

I set the byte array to size 128, but after performed the ToBase64String, the size is 172.

I expecting it to be 128.

how should I rectify this?




Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>