c# - Generate a printable HMAC Shared key in .Net -


i'm using hmacsha512 hash data using shared key. since key shared i'd printable characters ease of transport. i'm wondering best approach generating these keys.

i'm using getbytes() method of rngcryptoserviceprovider generate key, byte array returns contains non-printable characters. i'm wondering if secure base64 encode result or erode randomness , make things less secure? if isn't approach can suggest one?

i understand limiting keys printable characters limiting overall breadth of key space (ie: lopping off 1 of 8 bits), ok that.

if can handle not auto-generating key http://www.grc.com/passwords source of random key material.

base64 wouldn't reduce underlying entropy of byte array. generate key , use in raw form, base64 encode transport need be. you'd base64 decode raw form before use in new location. there no loss of entropy in operation. base64 encoding reduces entropy 6-bits per byte instead of 8, result of coding longer, overall entropy same.

the other way 24 random bytes 192-bits worth of entropy. base64 encoding give 32 character string (256-bits) still has original randomness , 192-bits of entropy. use shared key directly.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -