RE: Decoder

new topic     » goto parent     » topic index » view thread      » older message » newer message

Alex Blanchette wrote:
> 
> No, I can get the code, I already know that, I want it so the user types 
> in
> code, presses enter, and gets the "lamens"/decoded/english version of it
> 
> Thy name is but a short lived word,
> Thy life is a forever ending story...

OK, I know you weren't looking for a program but... something like this?

include get.e

constant
   Base16 = "0123456789ABCDEF"

integer nextchar
sequence encoded, decoded
decoded=""

encoded = prompt_string( "Enter codes (e.g. 48656C6C6F20576F726C64): " )

if length( encoded )/2 != floor( length( encoded )/2 ) then
   puts(1,"Error: Must have even number of characters")
   abort(1)
end if
for i = 1 to length( encoded ) by 2 do
   if not(find( encoded[i], Base16 )) or not(find( encoded[i+1], Base16 
)) then
      puts(1,"Error: Invalid character(s) found")
      abort(1)
   end if   
   nextchar = ( find( encoded[i], Base16 ) - 1 )*16 + find( 
encoded[i+1], Base16 ) - 1
   decoded &= nextchar
end for

puts(1,decoded)

-- Brian

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu