Vigenère cipher: Difference between revisions

Updated second D entry
(Updated second D entry)
Line 544:
s.toUpper.removechars("^A-Z").map!q{ a - 'A' };
 
string _v2s(R)(R v) /*pure /*nothrow*/ {
return v.map!(x => uppercase[x.mod(26)]).text;
}
 
enum encrypt = (in string txt, in string key) /*pure /*nothrow*/ =>
txt._s2v.zip(key._s2v.cycle).map!q{ a[0] + a[1] }._v2s;
 
enum decrypt = (in string txt, in string key) /*pure /*nothrow*/ =>
txt._s2v.zip(key._s2v.cycle).map!q{ a[0] - a[1] }._v2s;