MD5/Implementation: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Removed a superfluous comma.) |
(Updated to work with Nim 1.4: replaced ".. <" with "..<".) |
||
Line 3,666: | Line 3,666: | ||
srcIndex = offset |
srcIndex = offset |
||
for dstIndex in 0 .. |
for dstIndex in 0 ..< 16: |
||
chunk[dstIndex] = 0 |
chunk[dstIndex] = 0 |
||
for ii in 0 .. |
for ii in 0 ..< 4: |
||
chunk[dstIndex] = chunk[dstIndex] shr 8 |
chunk[dstIndex] = chunk[dstIndex] shr 8 |
||
chunk[dstIndex] = chunk[dstIndex] or (msg[srcIndex].uint32 shl 24) |
chunk[dstIndex] = chunk[dstIndex] or (msg[srcIndex].uint32 shl 24) |
||
Line 3,722: | Line 3,722: | ||
var sizePadding = newSeq[uint8](8) |
var sizePadding = newSeq[uint8](8) |
||
var size = msg.len * 8 |
var size = msg.len * 8 |
||
for ii in 0 .. |
for ii in 0 ..< 4: |
||
sizePadding[ii] = uint8(size and 0xff) |
sizePadding[ii] = uint8(size and 0xff) |
||
size = size shr 8 |
size = size shr 8 |
||
Line 3,776: | Line 3,776: | ||
var tmp = acc |
var tmp = acc |
||
for ii in 0 .. |
for ii in 0 ..< 4: |
||
result[dstIdx] = uint8(tmp and 0xff) |
result[dstIdx] = uint8(tmp and 0xff) |
||
tmp = tmp shr 8 |
tmp = tmp shr 8 |
||
Line 3,783: | Line 3,783: | ||
# Only needed to convert from string to uint8 sequence |
# Only needed to convert from string to uint8 sequence |
||
iterator items * (str : string) : uint8 = |
iterator items * (str : string) : uint8 = |
||
for ii in 0 .. |
for ii in 0 ..< len(str): |
||
yield str[ii].uint8 |
yield str[ii].uint8 |
||