summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-07-13 05:13:12 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-07-13 05:13:12 +0200
commitbc738d63a728ee6030cc224c8808990a6f641feb (patch)
tree0ab00b49c617a99fa9eaaf354458a77592f305dd /lib
parent2b862b74e0b0b7b4a18f4262356289fb921eaf0c (diff)
downloadNim-bc738d63a728ee6030cc224c8808990a6f641feb.tar.gz
no interval arithmetic anymore to construct implicit range types; breaking change
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/md5.nim12
-rw-r--r--lib/pure/securehash.nim4
-rw-r--r--lib/pure/strutils.nim2
3 files changed, 9 insertions, 9 deletions
diff --git a/lib/pure/md5.nim b/lib/pure/md5.nim
index 44b9ed0d4..1ff3a9824 100644
--- a/lib/pure/md5.nim
+++ b/lib/pure/md5.nim
@@ -78,10 +78,10 @@ proc encode(dest: var MD5Block, src: cstring) =
 proc decode(dest: var openArray[uint8], src: openArray[uint32]) =
   var i = 0
   for j in 0..high(src):
-    dest[i] = src[j] and 0xff'u32
-    dest[i+1] = src[j] shr 8 and 0xff'u32
-    dest[i+2] = src[j] shr 16 and 0xff'u32
-    dest[i+3] = src[j] shr 24 and 0xff'u32
+    dest[i] = uint8(src[j] and 0xff'u32)
+    dest[i+1] = uint8(src[j] shr 8 and 0xff'u32)
+    dest[i+2] = uint8(src[j] shr 16 and 0xff'u32)
+    dest[i+3] = uint8(src[j] shr 24 and 0xff'u32)
     inc(i, 4)
 
 proc transform(buffer: pointer, state: var MD5State) =
@@ -216,8 +216,8 @@ proc `$`*(d: MD5Digest): string =
   const digits = "0123456789abcdef"
   result = ""
   for i in 0..15:
-    add(result, digits[(d[i] shr 4) and 0xF])
-    add(result, digits[d[i] and 0xF])
+    add(result, digits[(d[i].int shr 4) and 0xF])
+    add(result, digits[d[i].int and 0xF])
 
 proc getMD5*(s: string): string =
   ## computes an MD5 value of `s` and returns its string representation
diff --git a/lib/pure/securehash.nim b/lib/pure/securehash.nim
index f141732a7..c19146669 100644
--- a/lib/pure/securehash.nim
+++ b/lib/pure/securehash.nim
@@ -148,13 +148,13 @@ proc sha1(src: cstring; len: int): Sha1Digest =
   while lastBlockBytes < endCurrentBlock:
 
     var value = uint32(src[lastBlockBytes + currentBlock]) shl
-                ((3'u32 - (lastBlockBytes and 3)) shl 3)
+                ((3'u32 - uint32(lastBlockBytes and 3)) shl 3)
 
     w[lastBlockBytes shr 2] = w[lastBlockBytes shr 2] or value
     inc(lastBlockBytes)
 
   w[lastBlockBytes shr 2] = w[lastBlockBytes shr 2] or (
-    0x80'u32 shl ((3'u32 - (lastBlockBytes and 3)) shl 3)
+    0x80'u32 shl ((3'u32 - uint32(lastBlockBytes and 3)) shl 3)
   )
 
   if endCurrentBlock >= 56:
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim
index 20b2657f6..346248a25 100644
--- a/lib/pure/strutils.nim
+++ b/lib/pure/strutils.nim
@@ -887,7 +887,7 @@ proc toHex*(x: BiggestInt, len: Positive): string {.noSideEffect,
     n = x
   result = newString(len)
   for j in countdown(len-1, 0):
-    result[j] = HexChars[n and 0xF]
+    result[j] = HexChars[(n and 0xF).int]
     n = n shr 4
     # handle negative overflow
     if n == 0 and x < 0: n = -1