(* q1.ml - Don Yang (uguu.org) 08/05/03 *) open String;; let template = "P.bK .bEaE.";; let data = "kfool#tlqog";; let key = 3;; let rec int_list_to_string lst k = match lst with a::b -> (make 1 (Char.chr (a lxor k)) ^ (int_list_to_string b k)) | [] -> "";; let rec string_to_int_list str = if str = "" then [] else Char.code (get str 0) :: string_to_int_list (sub str 1 ((length str) - 1));; let xor_string s k = int_list_to_string (string_to_int_list s) k;; let rec remove_space str = if str = "" then str else ( (let x = sub str 0 1 in if x = " " then "" else x) ^ (remove_space (sub str 1 ((length str) - 1))) );; let rec format_text template text = match template with x::y -> if x > 64 && x < 91 then ( let x = x - 64 in ( print_string (sub text 0 x); format_text y (sub text x ((length text) - x)) ) ) else ( if x > 96 && x < 123 then print_string (make (x - 96) ' ') else print_newline (); format_text y text ); | [] -> ();; format_text (string_to_int_list (remove_space template)) (remove_space ("header" ^ template ^ data ^ (xor_string data key)));;