mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
Implemented support for Nimble local cache with package directories with a checksum of the package at the end of their names. Now the compiler supports package paths in the form: * /path_to_nimble_cache_dir/pkgs/package_name-1.2.3- FEBADEAEA2345E777F0F6F8433F7F0A52EDD5D1B * /path_to_nimble_cache_dir/pkgs/package_name-#head- 042D4BE2B90ED0672E717D71850ABDB0A2D19CD2 * /path_to_nimble_cache_dir/pkgs/package_name-#branch-name- DBC1F902CB79946E990E38AF51F0BAD36ACFABD9 Related to nim-lang/nimble#127
24 lines
933 B
Nim
24 lines
933 B
Nim
import std/sha1
|
|
|
|
let hash1 = secureHash("a93tgj0p34jagp9[agjp98ajrhp9aej]")
|
|
doAssert hash1 == hash1
|
|
doAssert parseSecureHash($hash1) == hash1
|
|
|
|
template checkVector(s, exp: string) =
|
|
doAssert secureHash(s) == parseSecureHash(exp)
|
|
|
|
checkVector("", "da39a3ee5e6b4b0d3255bfef95601890afd80709")
|
|
checkVector("abc", "a9993e364706816aba3e25717850c26c9cd0d89d")
|
|
checkVector("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
|
"84983e441c3bd26ebaae4aa1f95129e5e54670f1")
|
|
|
|
proc testIsValidSha1Hash =
|
|
doAssert not isValidSha1Hash("")
|
|
doAssert not isValidSha1Hash("042D4BE2B90ED0672E717D71850ABDB0A2D19CD11")
|
|
doAssert not isValidSha1hash("042G4BE2B90ED0672E717D71850ABDB0A2D19CD1")
|
|
doAssert isValidSha1Hash("042D4BE2B90ED0672E717D71850ABDB0A2D19CD1")
|
|
doAssert isValidSha1Hash("042d4be2b90ed0672e717d71850abdb0a2d19cd1")
|
|
doAssert isValidSha1Hash("042d4be2b90ed0672e717D71850ABDB0A2D19CD1")
|
|
|
|
testIsValidSha1Hash()
|