Class Encoder
java.lang.Object
valorless.valorlessutils.encoding.Encoder
Utility class providing simple Caesar Cipher encoding and decoding methods.
The Caesar Cipher is a substitution cipher where each letter in the input is shifted by a specified number of positions in the alphabet. Non-letter characters remain unchanged.
This class supports both encoding and decoding with a customizable shift value.
Example Usage:
String original = "Hello, World!";
String encoded = Encoder.encode(original, 3); // "Khoor, Zruog!"
String decoded = Encoder.decode(encoded, 3); // "Hello, World!"
The class is stateless and thread-safe.-
Constructor Details
-
Encoder
public Encoder()
-
-
Method Details
-
encode
Encodes a message using the Caesar Cipher algorithm with a specified shift.- Parameters:
message
- The original message to encode.shift
- The number of positions to shift each letter in the alphabet.- Returns:
- The encoded message.
-
decode
Decodes an encoded message using the Caesar Cipher algorithm with a specified shift.- Parameters:
encodedMessage
- The encoded message to decode.shift
- The number of positions to shift each letter in the alphabet (use the same shift value used for encoding).- Returns:
- The decoded message.
-