RosettaCodeData/Task/Caesar-cipher/Objeck/caesar-cipher.objeck
Ingy döt Net 6f050a029e update
2013-06-05 21:47:54 +00:00

29 lines
669 B
Text

class Caesar {
function : native : Encode(enc : String, offset : Int) ~ String {
offset := offset % 26 + 26;
encoded := "";
enc := enc->ToLower();
each(i : enc) {
c := enc->Get(i);
if(c->IsChar()) {
j := (c - 'a' + offset) % 26;
encoded->Append(j + 'a');
}
else {
encoded->Append(c);
};
};
return encoded;
}
function : Decode(enc : String, offset : Int) ~ String {
return Encode(enc, offset * -1);
}
function : Main(args : String[]) ~ Nil {
enc := Encode("The quick brown fox Jumped over the lazy Dog", 12);
enc->PrintLine();
Decode(enc, 12)->PrintLine();
}
}