Anonymous user
Vigenère cipher: Difference between revisions
→{{header|D}}: less compact but faster
(Modified D version) |
(→{{header|D}}: less compact but faster) |
||
Line 318:
<lang d>import std.stdio, std.string;
string encrypt(string
string
foreach (
res ~= (c + key[res.length % $] - 2 * 'A') % 26 + 'A';
return encoded;▼
}
}
string decrypt(string
string
foreach (
res ~= (c - key[res.length % $] + 26) % 26 + 'A';
return decoded;▼
}
}
|