public static PublicKeyRecord Parse(string input) { PublicKeyRecord record = new PublicKeyRecord(); MatchCollection matches = Regex.Matches(input, @"[a-zA-Z]+=[^;]+(?=(;|\Z))"); foreach (Match m in matches) { string tag = m.Value.Substring(0, m.Value.IndexOf('=')); string value = m.Value.Substring(m.Value.IndexOf('=') + 1); if (tag.Equals("n")) record._n = value; else if (tag.Equals("p")) { value = value.Trim('\r', '\n').Replace(" ", ""); while ((value.Length % 4) != 0) value += "="; record._p64 = value; record._p = Convert.FromBase64String(record._p64); } else if (tag.Equals("k")) { if (value.Equals("rsa")) record._k = KeyType.Rsa; } else if (tag.Equals("g")) record._g = value; else if (tag.Equals("t")) record._t = value.Equals("y"); } return record; }