In the previous post, I had mentioned about the "Pig" latin, which offers some sort of "Perceived" privacy. This morning when I was watching Phineas and Ferb, they invent a new language called "Ferb" latin, so I thought since very less people know about that, we can very well use those rules instead. Here is the program to encode:
public static string
GetFerbLatinFromText(string strText)
{
string
strRetVal = string.Empty;
int i, j;
try
{
StringBuilder
sb = new StringBuilder();
char[]
chrLetters;
string[]
strWord = strText.Split(' ', '\n');
for (i
= 0; i < strWord.Length; i++)
{
chrLetters =
strWord[i].ToCharArray();
if
(chrLetters.Length > 2)
{
for
(j = 1; j < chrLetters.Length; j++)
{
sb.Append(Char.ToLower(chrLetters[j]));
}
sb.Append(Char.ToLower(chrLetters[0]));
sb.Append("erb ");
}
else
{
sb.Append(strWord[i]);
sb.Append(" ");
}
}
strRetVal = sb.ToString();
}
catch (Exception exp)
{
throw
exp;
}
return
strRetVal;
}
Code to decode the text :
public static string
GetTextFromFerbLatin(string strText)
{
string
strRetVal = string.Empty;
int i, j;
try
{
StringBuilder
sb = new StringBuilder();
char[]
chrLetters;
string[]
strWord = strText.Split(' ', '\n');
for (i
= 0; i < strWord.Length; i++)
{
chrLetters =
strWord[i].ToCharArray();
if
(chrLetters.Length > 2)
{
if(chrLetters.Length
>4)
sb.Append(Char.ToLower(chrLetters[chrLetters.Length - 4]));
for
(j = 0; j < chrLetters.Length-4; j++)
{
sb.Append(Char.ToLower(chrLetters[j]));
}
sb.Append(' ');
}
else
{
sb.Append(strWord[i]);
sb.Append("
");
}
}
strRetVal = sb.ToString();
}
catch (Exception exp)
{
throw
exp;
}
return
strRetVal;
}
Source code for this program can be downloaded from here : Link
Executable can be found here : Link
No comments:
Post a Comment