Example #1
0
        public string Translate(string input, LeetLevel leetLevel)
        {
            int    idx;
            string res    = string.Empty;
            Random random = new Random();

            foreach (char c in input)
            {
                if (c >= 97 && c <= 122)
                {
                    int relIndex = Convert.ToInt32(c) - 97;
                    switch (leetLevel)
                    {
                    case LeetLevel.Noob:
                        res += arrayOfDefinedArray[relIndex][0];
                        break;

                    case LeetLevel.Leet:
                        idx  = random.Next(arrayOfDefinedArray[relIndex].Length - 2);
                        res += arrayOfDefinedArray[relIndex][idx];
                        break;

                    case LeetLevel.Roxxor:
                        idx  = random.Next(1, arrayOfDefinedArray[relIndex].Length - 1);
                        res += arrayOfDefinedArray[relIndex][idx];
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    res += c;
                }
            }

            return(res);
        }
Example #2
0
        public string Translate(string input, LeetLevel leetLevel)
        {
            int    idx;
            string res    = string.Empty;
            Random random = new Random();

            foreach (char c in input)
            {
                if (dicoDefinedList.ContainsKey(c))
                {
                    switch (leetLevel)
                    {
                    case LeetLevel.Noob:
                        res += dicoDefinedList[c][0];
                        break;

                    case LeetLevel.Leet:
                        idx  = random.Next(dicoDefinedList[c].Count - 2);
                        res += dicoDefinedList[c][idx];
                        break;

                    case LeetLevel.Roxxor:
                        idx  = random.Next(1, dicoDefinedList[c].Count - 1);
                        res += dicoDefinedList[c][idx];
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    res += c;
                }
            }

            return(res);
        }