public static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
public static string GetString(byte[] bytes)
{
char[] chars = new char[bytes.Length / sizeof(char)];
System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
return new string(chars);
}
public string GetModuleFromXML(string pubKey)
{
int firstIndex = pubKey.IndexOf("<Modulus>");
int lastIndex = pubKey.LastIndexOf("</Modulus>");
string module = pubKey.Substring(firstIndex + 9, (lastIndex - firstIndex - 9));
return module;
}
public string GetExponentFromXML(string pubKey)
{
int firstIndex = pubKey.IndexOf("<Exponent>");
int lastIndex = pubKey.LastIndexOf("</Exponent>");
string exponent = pubKey.Substring(firstIndex + 10, (lastIndex - firstIndex - 10));
return exponent;
}
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
public static string GetString(byte[] bytes)
{
char[] chars = new char[bytes.Length / sizeof(char)];
System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
return new string(chars);
}
public string GetModuleFromXML(string pubKey)
{
int firstIndex = pubKey.IndexOf("<Modulus>");
int lastIndex = pubKey.LastIndexOf("</Modulus>");
string module = pubKey.Substring(firstIndex + 9, (lastIndex - firstIndex - 9));
return module;
}
public string GetExponentFromXML(string pubKey)
{
int firstIndex = pubKey.IndexOf("<Exponent>");
int lastIndex = pubKey.LastIndexOf("</Exponent>");
string exponent = pubKey.Substring(firstIndex + 10, (lastIndex - firstIndex - 10));
return exponent;
}