mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[chore] Update MD5 calls with new sha2 library (#6411)
Depends on <https://github.com/koreader/koreader-base/pull/1149>.
This commit is contained in:
2
base
2
base
Submodule base updated: 19a87bbc10...fac6e7c852
@@ -5,7 +5,7 @@ A global LRU cache
|
||||
local DataStorage = require("datastorage")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
local md5 = require("ffi/MD5")
|
||||
local md5 = require("ffi/sha2").md5
|
||||
|
||||
local CanvasContext = require("document/canvascontext")
|
||||
if CanvasContext.should_restrict_JIT then
|
||||
@@ -129,7 +129,7 @@ function Cache:check(key, ItemClass)
|
||||
end
|
||||
return self.cache[key]
|
||||
elseif ItemClass then
|
||||
local cached = self.cached[md5.sum(key)]
|
||||
local cached = self.cached[md5(key)]
|
||||
if cached then
|
||||
local item = ItemClass:new{}
|
||||
local ok, msg = pcall(item.load, item, cached)
|
||||
@@ -166,7 +166,7 @@ function Cache:serialize()
|
||||
|
||||
-- only dump cache item that requests serialization explicitly
|
||||
if cache_item.persistent and cache_item.dump then
|
||||
local cache_full_path = cache_path..md5.sum(key)
|
||||
local cache_full_path = cache_path..md5(key)
|
||||
local cache_file_exists = lfs.attributes(cache_full_path)
|
||||
|
||||
if cache_file_exists then break end
|
||||
|
||||
@@ -135,20 +135,20 @@ function Document:fastDigest(docsettings)
|
||||
if not result then
|
||||
logger.dbg("computing and storing partial_md5_checksum")
|
||||
local bit = require("bit")
|
||||
local md5 = require("ffi/MD5")
|
||||
local md5 = require("ffi/sha2").md5
|
||||
local lshift = bit.lshift
|
||||
local step, size = 1024, 1024
|
||||
local m = md5.new()
|
||||
local update = md5()
|
||||
for i = -1, 10 do
|
||||
file:seek("set", lshift(step, 2*i))
|
||||
local sample = file:read(size)
|
||||
if sample then
|
||||
m:update(sample)
|
||||
update(sample)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
result = m:sum()
|
||||
result = update()
|
||||
docsettings:saveSetting("partial_md5_checksum", result)
|
||||
end
|
||||
if tmp_docsettings then
|
||||
|
||||
@@ -2,7 +2,7 @@ local DocumentRegistry = require("document/documentregistry")
|
||||
local DocSettings = require("docsettings")
|
||||
local ReadHistory = require("readhistory")
|
||||
local logger = require("logger")
|
||||
local md5 = require("ffi/MD5")
|
||||
local md5 = require("ffi/sha2").md5
|
||||
local util = require("util")
|
||||
|
||||
local MyClipping = {
|
||||
@@ -222,7 +222,7 @@ function MyClipping:getImage(image)
|
||||
--doc:clipPagePNGFile(image.pos0, image.pos1,
|
||||
--image.pboxes, image.drawer, "/tmp/"..md5(png)..".png")
|
||||
doc:close()
|
||||
if png then return { png = png, hash = md5.sum(png) } end
|
||||
if png then return { png = png, hash = md5(png) } end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ local Event = require("ui/event")
|
||||
local Math = require("optmath")
|
||||
local Screen = Device.screen
|
||||
local logger = require("logger")
|
||||
local md5 = require("ffi/MD5")
|
||||
local md5 = require("ffi/sha2").md5
|
||||
local random = require("random")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
@@ -386,7 +386,7 @@ function KOSync:doRegister(username, password)
|
||||
}
|
||||
-- on Android to avoid ANR (no-op on other platforms)
|
||||
Device:setIgnoreInput(true)
|
||||
local userkey = md5.sum(password)
|
||||
local userkey = md5(password)
|
||||
local ok, status, body = pcall(client.register, client, username, userkey)
|
||||
if not ok then
|
||||
if status then
|
||||
@@ -422,7 +422,7 @@ function KOSync:doLogin(username, password)
|
||||
service_spec = self.path .. "/api.json"
|
||||
}
|
||||
Device:setIgnoreInput(true)
|
||||
local userkey = md5.sum(password)
|
||||
local userkey = md5(password)
|
||||
local ok, status, body = pcall(client.authorize, client, username, userkey)
|
||||
if not ok then
|
||||
if status then
|
||||
|
||||
@@ -288,21 +288,21 @@ function ReaderStatistics:partialMd5(file)
|
||||
return nil
|
||||
end
|
||||
local bit = require("bit")
|
||||
local md5 = require("ffi/MD5")
|
||||
local md5 = require("ffi/sha2").md5
|
||||
local lshift = bit.lshift
|
||||
local step, size = 1024, 1024
|
||||
local m = md5.new()
|
||||
local update = md5()
|
||||
local file_handle = io.open(file, 'rb')
|
||||
for i = -1, 10 do
|
||||
file_handle:seek("set", lshift(step, 2*i))
|
||||
local sample = file_handle:read(size)
|
||||
if sample then
|
||||
m:update(sample)
|
||||
update(sample)
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
return m:sum()
|
||||
return update()
|
||||
end
|
||||
|
||||
function ReaderStatistics:createDB(conn)
|
||||
|
||||
Reference in New Issue
Block a user