public static string Decrypt(string key, string message)
byte[] phone = Encoding.UTF8.GetBytes(key);
byte[] messageChars = Convert.FromBase64String(message);
byte[] output = new byte[messageChars.Length];
for (int i = 0; i < messageChars.Length; i++)
output[i] = Convert.ToByte((messageChars[i] ^ phone[i % phone.Length]) & byte.MaxValue);
return Encoding.UTF8.GetString(output);
public static string Encrypt(string key, string message)
byte[] phone = Encoding.UTF8.GetBytes(key);
byte[] messageChars = Encoding.UTF8.GetBytes(message);
byte[] output = new byte[messageChars.Length];
for (int i = 0; i < messageChars.Length; i++)
output[i] = Convert.ToByte((messageChars[i] ^ phone[i % phone.Length]) & byte.MaxValue);
return Convert.ToBase64String(output);
public static void Main()
string TelephoneNumber = "+445558473622";
string Flag = "JyApHhkfQDQMCmo5JRkmGydyYklRMx03BnUCdCcPNDMOLn0IYh5JDT4OWwYKdQJyLg==";
string password = Decrypt(TelephoneNumber, "alhYbFpASnZWQFNzQE52UVlaW19gWGZFH2BOR11GQVBWV1J6RXRHX11YUA==");
Console.WriteLine("Password is: " + password);
string key = Encrypt(password, TelephoneNumber);
Console.WriteLine("Key is: " + key);
string flag = Decrypt(key, Flag);
Console.WriteLine("Flag is: " + flag);