A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Rot13 in Pascal page! Here, you'll find the source code for this program as well as a description of how the program works.
program Rot13;
{$mode objfpc}{$H+}
uses
SysUtils;
procedure ShowUsage;
begin
Writeln('Usage: please provide a string to encrypt');
Halt(1);
end;
function Rot13(const S: string): string;
var
ch: char;
begin
Result := '';
for ch in S do
case ch of
'A'..'Z':
Result += Chr(((Ord(ch) - Ord('A') + 13) mod 26) + Ord('A'));
'a'..'z':
Result += Chr(((Ord(ch) - Ord('a') + 13) mod 26) + Ord('a'));
else
Result += ch;
end;
end;
var
Input: string;
begin
if ParamCount <> 1 then
ShowUsage;
Input := ParamStr(1);
if Input = '' then
ShowUsage;
Writeln(Rot13(Input));
end.
Rot13 in Pascal was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.