Feedback

Leetspeak Klasse

ƒ““

using System;
using System.Collections.Generic;
using System.Text;

namespace Leet
{
    public class LeetGenerator
    {
        readonly Dictionary<char, string[]> _dict;
        readonly Random _rnd;

        public string GetLeetString(string input)
        {
            var sb = new StringBuilder();
            input = input.ToUpper().Replace(" ", "  ");

            foreach (var c in input)
            {
                if (_dict.ContainsKey(c))
                    sb.Append(_dict[c][_rnd.Next(_dict[c].Length)]);
                else
                    sb.Append(c);
            }
            return sb.ToString();
        }

        public LeetGenerator()
        {
            _rnd = new Random();
            _dict = new Dictionary<char, string[]>
            {
                {'A', new [] {"4", "@", "/\", "/-\", "?", "^", "α", "λ"}},
                {'B', new [] {"8", "|3", "ß", "l³", "13", "I3", "J3"}},
                {'C', new [] {"(", "[", "<", "©", "¢"}},
                {'D', new [] {"|)", "|]", "Ð", "đ", "1)"}},
                {'E', new [] {"3", "€", "&", "£", "ε"}},
                {'F', new [] {"|=", "PH", "|*|-|", "|""