Skip to content

Commit

Permalink
Add Rot13 in Beef (#3732)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzuckerm authored Jan 22, 2024
1 parent ca42045 commit 9cbb926
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions archive/b/beef/Rot13.bf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;

namespace Rot13;

class Program
{
public static void Usage()
{
Console.WriteLine("Usage: please provide a string to encrypt");
Environment.Exit(0);
}

public static void Rot13(StringView str, ref String result)
{
result.Clear();
result.Reserve(str.Length);
for (char8 ch in str)
{
char8 chLower = ch.ToLower;
if (chLower >= 'a' && chLower <= 'm')
{
ch += 13;
}
else if (chLower >= 'n' && chLower <= 'z')
{
ch -= 13;
}

result += ch;
}
}

public static int Main(String[] args)
{
if (args.Count < 1 || args[0].Length < 1)
{
Usage();
}

String result = scope String();
Rot13(args[0], ref result);
Console.WriteLine(result);
return 0;
}
}

0 comments on commit 9cbb926

Please sign in to comment.