Search | Synergex.com | Contact Us | Resource Center Login | Home|
News

What is the output of the following program? See if you can figure it out without running it.

main
proc
    open(1,o,"TT:")
    writes(1,unmangle
  &  ("ccbiagagebaaakefahepejchfjbnaealfiaoehcfdbaafnebfafnbbejaaepbhaaaabo",
  &  "what does it say?"))
end

function unmangle
in req text, a
in req key, a
record
    index, int
    kindex, int
    new, string
proc
    new = ''
    kindex = 1
    for index from 1 thru ^size(text) by 2
      begin
        data h, a2
        data h2, a2
        h2 = hex(decml(text(index:1)) - 97, 1)
        h(1:1) = h2(2:1)
        h2 = hex(decml(text(index+1:1)) - 97, 1)
        h(2:1) = h2(2:1)
        new = new + char(^x(h) .bxor. ^i(key(kindex:1)))
        incr kindex
        if (kindex > ^size(key))
          kindex = 1
      end
    freturn new
end

Which answer is correct?

a. "My hovercraft's quite full of eels"
b. "what does it say?what does it say?"
c. "Upgrade to Synergy/DE 9.5.1 today!"
d. "Any questions, ask Richard Morris."

ANSWER: (c)

This example represents one half of a not very secure encryption algorithm. ( Don't use it in your own applications.)   We omitted the other half (the encryption phase) from the example in order to increase your frustration, but it performs the opposite operation of the ”unmangle”
function above.  To wit:

1. Each character of the original string is bit-XORed against a succeeding character in a key.  XOR has the useful property of being reversible by applying a second XOR with the same key.

2. The hexadecimal value of the resulting character is then split into two hex digits. The value of each is added to lowercase “ a ” to produce two letters from “ a ” thru “ p ”.

3. These values are concatenated into the encrypted string, which is therefore twice as long as the original.

If you haven't already upgraded to 9.5.1, then get on with it!

As for answer (a), that's a translator's favorite.  Answer (b) was actually the result from the first version of this program, which contained a bug that caused h to always be "00". Half-credit for answer (d), because that one's right in any situation.

 

More information about News and Events

Contact Synergex to learn more about  News and Events