using System;
public class Test
{
public static void Main()
{
String plainAlphabet = "abcdefghijklmnopqrstuvwxyz";
String cipherAlphabet = "zyxwvutsrqponmlkjihgfedcba";
String text = "Some sensitive text that only humans must be able to read";
String encodedText = encrypt(plainAlphabet, cipherAlphabet, text);
Console.WriteLine(encodedText);
}
public static String encrypt(String plain, String cipher, String text) {
plain = plain + plain.ToUpper();
cipher = cipher + cipher.ToUpper();
String newText = "";
for(int i=0; i<text.Length; i++) {
char c = text[i];
int index = plain.IndexOf(c);
if(index >= 0 && index < cipher.Length) {
newText += cipher[index];
} else {
newText += c;
}
}
return newText;
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCVN0cmluZyBwbGFpbkFscGhhYmV0ID0gImFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IjsKCQlTdHJpbmcgY2lwaGVyQWxwaGFiZXQgPSAienl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmEiOwoJCVN0cmluZyB0ZXh0ID0gIlNvbWUgc2Vuc2l0aXZlIHRleHQgdGhhdCBvbmx5IGh1bWFucyBtdXN0IGJlIGFibGUgdG8gcmVhZCI7CiAKCQlTdHJpbmcgZW5jb2RlZFRleHQgPSBlbmNyeXB0KHBsYWluQWxwaGFiZXQsIGNpcGhlckFscGhhYmV0LCB0ZXh0KTsKCQlDb25zb2xlLldyaXRlTGluZShlbmNvZGVkVGV4dCk7Cgl9CgkKCXB1YmxpYyBzdGF0aWMgU3RyaW5nIGVuY3J5cHQoU3RyaW5nIHBsYWluLCBTdHJpbmcgY2lwaGVyLCBTdHJpbmcgdGV4dCkgewoJICAgIHBsYWluID0gcGxhaW4gKyBwbGFpbi5Ub1VwcGVyKCk7CgkgICAgY2lwaGVyID0gY2lwaGVyICsgY2lwaGVyLlRvVXBwZXIoKTsKCSAKCSAgICBTdHJpbmcgbmV3VGV4dCA9ICIiOwoJICAgIGZvcihpb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