I can't seem to get this to work after converting it to C#
I need it to work like the Java one but I can't seem to be able to do that what am I doing wrong?
Can anyone supply a fix and explain it please?
C#:
public static string Encrypt1(string strIn)
{
string strOut = "";
int lenIn = strIn.Length;
int i = 0;
while (i < lenIn)
{
double numRand = (int)Math.Floor(new Random().NextDouble() * 66) + 36;
strOut += Convert.ToString((int)(strIn[i] + (char)numRand), 27) +
Convert.ToString((int)numRand, 27);
i++;
}
return strOut;
}
Java:
public String Encrypt1(String strIn) {
String strOut = "";
int lenIn = strIn.length();
int i = 0;
double numRand;
while (i < lenIn) {
numRand = Math.floor(Math.random() * 66) + 36;
strOut += Integer.toString((int)(strIn.charAt(i) + (char)numRand), 27) +
Integer.toString((int)numRand, 27);
i++;
}
return strOut;
}
The error:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Invalid Base.
Error line:
strOut += Convert.ToString((int)(strIn[i] + (char)numRand), 27) +
Convert.ToString((int)numRand, 27);