Anonymous user
Playfair cipher: Difference between revisions
Updated D entry
m (→{{header|NetRexx}}: reorder args for cipher method) |
(Updated D entry) |
||
Line 156:
string[string] enc, dec;
this(in string key, in string from_ = "J", in string to_ = null)
/*pure nothrow*/ {
this.from = from_;
if (to_.empty)
Line 187 ⟶ 188:
}
private string _canonicalize(in string s) const
return s.toUpper.removechars("^A-Z").replace(from, to);
}
string encode(in string s) const /*pure*/ {
return _canonicalize(s)
.matchAll(r"(.)(?:(?!\1)(.))?".regex)
Line 209 ⟶ 210:
void main() {
/*immutable*/ const pf = Playfair("Playfair example");
immutable orig = "Hide the gold in...the TREESTUMP!!!";
writeln("Original: ", orig);
|