Mercurial > projects > dcrypt
comparison dcrypt/crypto/padding/NullByte.d @ 10:cd376996cdb3
Renamed SymmetricCipher back to Cipher (we don't support any other kind atm, I'll deal with it when we do.). Added BlockCipherWrapper for the encryption of arbitrary streams with or without padding. Removed hashByName, and replaced it with createHash. Re-did the high-level API, and filled out Crypto. Added cipher creation via createCipher. Added dsk to the CONTRIBUTORS file for helping with the design of the high-level API.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Wed, 20 Aug 2008 20:08:07 -0400 |
parents | 0e08791a1418 |
children | 8b5eaf3c2979 |
comparison
equal
deleted
inserted
replaced
9:29b910949588 | 10:cd376996cdb3 |
---|---|
17 class NullByte : BlockCipherPadding { | 17 class NullByte : BlockCipherPadding { |
18 char[] name() { | 18 char[] name() { |
19 return "NullByte"; | 19 return "NullByte"; |
20 } | 20 } |
21 | 21 |
22 /* Assumes input_ is a multiple of the underlying | 22 ubyte[] pad(uint len) { |
23 * block cipher's block size. | 23 ubyte[] output = new ubyte[len]; |
24 */ | 24 |
25 uint padBlock(void[] input_, uint inOff) { | 25 output[0..output.length] = 0; |
26 ubyte[] input = cast(ubyte[]) input_; | |
27 | 26 |
28 uint len = (input.length - inOff); | 27 return output; |
29 | |
30 input[inOff..input.length] = 0; | |
31 | |
32 return len; | |
33 } | 28 } |
34 | 29 |
35 uint padLength(void[] input_) { | 30 uint unpad(void[] input_) { |
36 ubyte[] input = cast(ubyte[]) input_; | 31 ubyte[] input = cast(ubyte[]) input_; |
37 | 32 |
38 uint len = input.length; | 33 uint len = input.length; |
39 while (len-- > 0) | 34 while (len-- > 0) |
40 if (input[len-1] != 0) break; | 35 if (input[len-1] != 0) break; |