Software /
code /
verse
Comparison
util/sha1.lua @ 111:75c73ac9d5a6
util.sha1: Truncate to a single return result when returning the binary form of the hash
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 25 Aug 2010 13:19:53 +0100 |
parent | 105:0f2446a9f65f |
child | 486:6416ea3fff86 |
comparison
equal
deleted
inserted
replaced
110:3fca7dd127df | 111:75c73ac9d5a6 |
---|---|
130 local hex = ToHex(h0)..ToHex(h1)..ToHex(h2) | 130 local hex = ToHex(h0)..ToHex(h1)..ToHex(h2) |
131 ..ToHex(h3)..ToHex(h4); | 131 ..ToHex(h3)..ToHex(h4); |
132 if hexres then | 132 if hexres then |
133 return hex; | 133 return hex; |
134 else | 134 else |
135 return hex:gsub("..", function (byte) | 135 return (hex:gsub("..", function (byte) |
136 return string.char(tonumber(byte, 16)); | 136 return string.char(tonumber(byte, 16)); |
137 end); | 137 end)); |
138 end | 138 end |
139 end | 139 end |
140 | 140 |
141 _G.sha1 = {sha1 = sha1}; | 141 _G.sha1 = {sha1 = sha1}; |
142 return _G.sha1; | 142 return _G.sha1; |