一个更伪代码的版本。
// Maps some characters such that
// 0 ->'0'
// 9 ->'9'
// 10 ->'a'
// 35 ->'z'
// 36 ->'A'
// 61 ->'Z'
Let constant characters = List ('0'..'9', 'a'..'z', 'A'..'Z')
Let constant size = length of characters
Function LogBase(number base, number x)
Return LogBase10(x) / LogBase10(base)
Function LeftMostPosition(unsigned integer message)
Return Floor(LogBase(size,message))
Function ShiftRight(unsigned integer message, unsigned integer numberOfPositions)
Return Floor(message / (size to the numberOfPositions power))
Function ShiftLeft(unsigned integer message, unsigned integer numberOfPositions)
Return message * (size to the numberOfPositions power)
Function Decode(unsigned integer message)
Let var buffer be a string buffer
// Runs a number of times equal to LeftMostPosition(message) + 1
Count position from LeftMostPosition(message) down through 0
// Get the symbol from the left side of the message
Let var index = ShiftRight(message, position)
// Add the decoded character
To buffer, add characters[index]
// And then remove it from the incoming message
Let message = message - ShiftLeft(index, position)
Return contents of buffer