MD5/Implementation: Difference between revisions

no edit summary
No edit summary
Line 28:
 
=={{header|Ada}}==
note: this could be dependantdependent on the endianness of the machine it runs on - not tested on big endian.
 
md5.ads:
Line 974:
}
 
var shift = [...]uint{7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21}
var table [64]uint32
 
func init() {
for i := range table {
dtable[i] := uint32((1 << 32) * math.Abs(math.Sin(float64(i + 1))))
table[i] = uint32((1 << 32) * d)
}
}
Line 1,282 ⟶ 1,281:
 
=={{header|Java}}==
{{works with|Java|1.5+}}
 
Based on RFC-1321.
<lang java>
Line 1,288 ⟶ 1,287:
{
 
private static final int INIT_A = 0x67452301;
private static final int INIT_B = (int)0xEFCDAB89L;
private static final int INIT_C = (int)0x98BADCFEL;
private static final int INIT_D = 0x10325476;
private static final int[] SHIFT_AMTS = {
7, 12, 17, 22,
5, 9, 14, 20,
Line 1,300 ⟶ 1,299:
};
private static final int[] TABLE_T = new int[64];
static
{
for (int i = 0; i < 64; i++)
TABLE_T[i] = scaleToInt(int)(long)((1L << 32) * Math.abs(Math.sin(i + 1)));
}
 
private static int scaleToInt(double d)
{
// Converts IEEE-754 double from 0 to 1.0 to the range of an unsigned int
return (int)(long)((1L<<32) * d);
}
Anonymous user