Skip to content

Instantly share code, notes, and snippets.

@andrewathalye
Last active September 16, 2022 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewathalye/14951e381a92f977c0ccc9e002f72104 to your computer and use it in GitHub Desktop.
Save andrewathalye/14951e381a92f977c0ccc9e002f72104 to your computer and use it in GitHub Desktop.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
use Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
with Interfaces; use Interfaces;
procedure Destiny_String_Example
is
-- Exceptions
Skip_String : exception;
-- Constants
S : constant String := "6OBCMF" & ASCII.SOH & "UP" & ASCII.SOH & "+PJO";
-- Subprograms
function Decipher (
S : String;
Obf : Unsigned_16) return String
is
WW : Wide_Wide_String := Decode (S);
begin
Convert_Strings :
for WWC of WW loop
WWC := Wide_Wide_Character'Val (
Wide_Wide_Character'Pos (WWC) + Obf);
if Wide_Wide_Character'Pos (WWC) not in 16#20# .. 16#7F# then
raise Skip_String;
end if;
end loop Convert_Strings;
return Encode (WW);
end Decipher;
begin
Outer :
for O in 1 .. 255 loop
begin
Put_Line (Decipher (S, Unsigned_16 (O)));
exception
when Skip_String => null;
end;
end loop Outer;
end Destiny_String_Example;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment