Data Encryption Standard: Difference between revisions

m
touched up implementation
m (touched up implementation)
Line 1,203:
}
 
/* any padding is assumed to be in the form of trailing zeros following 0DOA;
only the zeros will be removed */
ubyte[] decrypt(const ubyte[] key, const ubyte[] encoded) in {
assert(key.length == 8, "Incorrect key size");
Line 1,243 ⟶ 1,241:
// split 'kp' in half and process the resulting series of 'c' and 'd'
BitArray[] c;
BitArray[] d;
foreach (_; 0..18) {
c ~= bitArrayOfSize(56);
}
BitArray[] d;
foreach (_; 0..18) {
d ~= bitArrayOfSize(28);
}
foreach (i; 0..28) {
c[0][i] = kp[i];
}
foreach (i; 0..28) {
d[0][i] = kp[i + 28];
}
Line 1,302 ⟶ 1,296:
foreach (i; 0..32) {
left[0][i] = mp[i];
}
foreach (i; 0..32) {
right[0][i] = mp[i + 32];
}
Line 1,434 ⟶ 1,426:
writeln;
}
}
}</lang>
{{out}}
<pre>Key : 133457799BBCDFF1
1,452

edits