comparison dcrypt/crypto/Hash.d @ 32:2b4bccdc8387

Added version() statements to play nice with D2's current feelings about const. Changed a few methods (addEntropy and read in the base PRNG class, and the constructor for ParametersWithIV) to accept void[] in place of ubyte[].
author Thomas Dixon <reikon@reikon.us>
date Tue, 12 May 2009 22:09:33 -0400
parents 21847420b1ac
children b9f8aa42a547
comparison
equal deleted inserted replaced
31:f429c5e9dd69 32:2b4bccdc8387
32 { 32 {
33 buffer = new ubyte[blockSize]; 33 buffer = new ubyte[blockSize];
34 ubyte[] input = cast(ubyte[]) input_; 34 ubyte[] input = cast(ubyte[]) input_;
35 if (input) 35 if (input)
36 update(input); 36 update(input);
37 }
38
39 /** Play nice with D2's idea of const. */
40 version (D_Version2)
41 {
42 this (string input_)
43 {
44 return this(cast(ubyte[])input_);
45 }
37 } 46 }
38 47
39 /** Returns: The block size of the hash function in bytes. */ 48 /** Returns: The block size of the hash function in bytes. */
40 abstract uint blockSize(); 49 abstract uint blockSize();
41 50
81 90
82 if (input.length - i) 91 if (input.length - i)
83 buffer[index..index+(input.length-i)] = input[i..input.length]; 92 buffer[index..index+(input.length-i)] = input[i..input.length];
84 93
85 return this; 94 return this;
95 }
96
97 /** Play nice with D2's idea of const. */
98 version (D_Version2)
99 {
100 Hash update(string input_)
101 {
102 return update(cast(ubyte[])input_);
103 }
86 } 104 }
87 105
88 /** Hash function's internal transformation. */ 106 /** Hash function's internal transformation. */
89 protected abstract void transform(ubyte[] input); 107 protected abstract void transform(ubyte[] input);
90 108