-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRot18.cs
More file actions
executable file
·32 lines (27 loc) · 1.05 KB
/
Rot18.cs
File metadata and controls
executable file
·32 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Collections.Generic;
using System.Linq;
namespace ClipChanger
{
public static class Rot18
{
private static readonly char[] _source = ("abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789").ToCharArray();
private static Dictionary<char, char> _map = _source.Select((x, i) => new {x, i})
.ToDictionary(y => y.x,
y =>
_source[(y.i + (_source.Length/2))%_source.Length]);
public static string Convert(string input)
{
return new string(input.Select(Convert).ToArray());
}
public static char Convert(char input)
{
if (_map.ContainsKey(input))
{
return _map[input];
}
return input;
}
}
}