How do I calculate a REBOL 3 module checksum?
It's possible in REBOL 3 to calculate a SHA1 module checksum. When REBOL loads a module, it compares its checksum against the checksum of the loaded module, and if the two do not match, an error is generated, viz. access error: invali开发者_JAVA技巧d checksum (tampered file)
.
No matter how I try, I can't seem to create a module checksum that REBOL 3 likes. When I look at the documentation for import
, its /check
refinement says to use checksum/secure
of mold/flat
. I've tried all sorts of variations of this with no luck:
import/check %module.r checksum/secure to-binary mold/flat load/all %module.r import/check %module.r checksum/secure to-binary mold/flat load %module.r import/check %module.r checksum/secure to-binary mold/only/flat load/all %module.r import/check %module.r checksum/secure to-binary mold/only/flat load %module.r import/check %module.r checksum/secure read %module.r
and so on. None of it works. There's got to be some simple thing I'm doing wrong.
Here is the answer:
import/check %module.r checksum/secure to-binary mold/flat load/unbound/header %module.r
Of course, ordinarily you would pre-calculate the checksum and use it as a literal, otherwise it wouldn't do you much good as a security check:
import/check %module.r #{A3CD837D0CF843302221C074E88A64AA0147E07E}
精彩评论