I'm trying to pass a random number to a character generator that will then return a random string with the length passed to it.
int rndn = rnd.Next(20, 40);
byte[] strarr = Program.StringToByteArray(Program.GetUniqueKey(rndn));
The StringToByteArray is as follows:
public static byte[] StringToByteArray(String hex)
{
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}
If I pass a number manually to it like so:
byte[] strarr = Program.StringToByteArray(Program.GetUniqueKey(25));
It will work correctly and pass back a random string 25 chars long.
What would be causing this?
Aucun commentaire:
Enregistrer un commentaire