From:	RTPARK::RLB  "Bob Boyd 8*565-3627  06-Oct-1987 1015"  6-OCT-1987 10:15
To:	ARISIA::EVERHART
Subj:	for your goody bag -- this was so obvious once I looked at it.

From:	RTPARK::RLB  "Bob Boyd 8*565-3627  06-Oct-1987 1011"  6-OCT-1987 10:11
To:	WATTERS,BAEDER,BENZ,FLEMING,RLB         
Subj:	CAESAR.TPU aka ROT13

!Last Modified:   6-OCT-1987 09:59:36.49, By: RLB 
! CAESAR encoding for TPU
! cheap encryption device.
procedure rot13( input_buffer);
translate(input_buffer,
	"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM",
	"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
endprocedure;

! encrypt with a selected rotation factor
procedure rot( input_buffer,base)
	local	table_in,table_out;
	rot_table(base, table_in, table_out);
	translate(input_buffer,table_out,table_in);
endprocedure;

procedure rot_decrypt(input_buffer,base);
	rot(input_buffer,26-base);
endprocedure;

Procedure Rot_Table(base, table_in, table_out)
local	i, my_base, cap_a, lower_a, char_code,
	lower_table, upper_table;
table_in := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
table_out := ""; lower_table := ""; upper_table:="";
if base=0 then my_base := 13; else my_base := base; endif;
lower_a := 97; cap_a := 65;
! build the translation tables
i := 1;
loop
	char_code := (i+my_base-1)-26*((i+my_base-1)/26);
	lower_table := lower_table + ascii(lower_a+ char_code);
	upper_table := upper_table + ascii(cap_a+ char_code);
	i:=i+1;
	exitif i>26;
endloop;
! combine the translation pieces
table_out := lower_table+upper_table;
endprocedure;
