(Python) ROL by Thomas Roccia (fr0gger)

Created the Tuesday 13 December 2022. Updated 4 days, 11 hours ago.

Description:

The original message is first encoded using the ROL algorithm and the defined rotation value. The encoded message is then printed to the screen. The same rotation value is then used to decode the encoded message, resulting in the original message. This example demonstrates how the ROL algorithm can be used to encode and decode messages in a simple and easily reversible way.

Code

            # Define the original message to be encoded
message = "Hello, world!"

# Define the rotation value
rotation_value = 3

# Encode the message using the ROL algorithm and the defined rotation value
encoded_message = ""
for char in message:
  if char.isalpha():
    encoded_message += chr((ord(char) - ord("A") + rotation_value) % 26 + ord("A"))
  else:
    encoded_message += char

# Print the resulting encoded message
print(encoded_message)

# Decode the encoded message using the ROL algorithm and the same rotation value
decoded_message = ""
for char in encoded_message:
  if char.isalpha():
    decoded_message += chr((ord(char) - ord("A") - rotation_value) % 26 + ord("A"))
  else:
    decoded_message += char

# Print the resulting decoded message
print(decoded_message)