Windows Python / ROL
Author | Thomas Roccia (fr0gger) |
Platform | Windows |
Language | Python |
Technique | ROL |
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)
Created
December 13, 2022
Last Revised
April 22, 2024