mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
* Random hash generation.
This commit is contained in:
parent
15251fe480
commit
cfbd495049
1 changed files with 15 additions and 0 deletions
|
|
@ -45,6 +45,15 @@ bool PathHash::operator <(const PathHash & hash2) const
|
|||
}
|
||||
|
||||
|
||||
PathHash generateRandomPathHash()
|
||||
{
|
||||
Hash hash(htSHA256);
|
||||
for (unsigned int i = 0; i < hash.hashSize; ++i)
|
||||
hash.hash[i] = rand() % 256; // !!! improve
|
||||
return PathHash(hash);
|
||||
}
|
||||
|
||||
|
||||
struct CopySink : DumpSink
|
||||
{
|
||||
string s;
|
||||
|
|
@ -150,6 +159,12 @@ int main(int argc, char * * argv)
|
|||
{
|
||||
verbosity = (Verbosity) ((int) 10);
|
||||
|
||||
srand(time(0));
|
||||
|
||||
debug(format("%1%") % generateRandomPathHash().toString());
|
||||
debug(format("%1%") % generateRandomPathHash().toString());
|
||||
debug(format("%1%") % generateRandomPathHash().toString());
|
||||
|
||||
Path p = addToStore("./foo", PathHash(parseHash32(htSHA256, "8myr6ajc52b5sky7iplgz8jv703ljc0q")));
|
||||
|
||||
cout << p << endl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue