All pastes #565542 Raw Edit

Something

public text v1 · immutable
·published 2007-06-14 01:05 UTC
rendered paste body
function Alphabet takes nothing returns string
    return "[],.-()_ 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
endfunction
function EncryptionPairs takes integer i returns string
    if i < 10 then
        return "0" + I2S( i )
    endif
    return I2S( i )
endfunction
function DecryptionPairs takes string s returns string
    if SubString( s, 0, 1 ) == "0" then
        return SubString( s, 1, 1 )
    endif
    return s
endfunction

function Encryption takes string input returns string
    local integer array i
    local string array s
    loop
        exitwhen i[1] >= StringLength( input )   
        set s[1] = SubString( input, i[1], i[1] + 1 )
        loop
            exitwhen i[2] >= StringLength( Alphabet() )
            if s[1] == SubString( Alphabet(), i[2], i[2] + 1) then
                set s[2] = s[2] + EncryptionPairs( i[2] )
            endif
            set i[2] = i[2] + 1
        endloop
        set i[1] = i[1] + 1
        set i[2] = 0  
    endloop
    return s[2]         
endfunction