Some more stdlib refactoring removing duplicate code. (0.38.9)
This commit is contained in:
parent
54d94a1f3d
commit
794a2354d6
11 changed files with 18 additions and 112 deletions
|
|
@ -45,21 +45,12 @@ class SHA512()
|
|||
i = i + 2
|
||||
return arr
|
||||
|
||||
fun two_hex(this, n)
|
||||
n = n % 256
|
||||
hexd = "0123456789abcdef"
|
||||
number hi = (n / 16) % 16
|
||||
number lo = n % 16
|
||||
c1 = substr(hexd, hi, 1)
|
||||
c2 = substr(hexd, lo, 1)
|
||||
return join([c1, c2], "")
|
||||
|
||||
fun bytes_to_hex(this, arr)
|
||||
out = []
|
||||
number i = 0
|
||||
number L = len(arr)
|
||||
while i < L
|
||||
push(out, this.two_hex(arr[i]))
|
||||
push(out, two_hex(arr[i]))
|
||||
i = i + 1
|
||||
return join(out, "")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue