MCPcopy Create free account
hub / github.com/LUX-Core/lux / InformationDisperseFile

Function InformationDisperseFile

src/cryptopp/test.cpp:702–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700}
701
702void InformationDisperseFile(int threshold, int nShares, const char *filename)
703{
704 CRYPTOPP_ASSERT(threshold >= 1 && threshold <=1000);
705 if (threshold < 1 || threshold > 1000)
706 throw InvalidArgument("InformationDisperseFile: " + IntToString(nShares) + " is not in range [1, 1000]");
707
708 ChannelSwitch *channelSwitch = NULL;
709 FileSource source(filename, false, new InformationDispersal(threshold, nShares, channelSwitch = new ChannelSwitch));
710
711 vector_member_ptrs<FileSink> fileSinks(nShares);
712 string channel;
713 for (int i=0; i<nShares; i++)
714 {
715 char extension[5] = ".000";
716 extension[1]='0'+byte(i/100);
717 extension[2]='0'+byte((i/10)%10);
718 extension[3]='0'+byte(i%10);
719 fileSinks[i].reset(new FileSink((string(filename)+extension).c_str()));
720
721 channel = WordToString<word32>(i);
722 fileSinks[i]->Put((const byte *)channel.data(), 4);
723 channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL);
724 }
725
726 source.PumpAll();
727}
728
729void InformationRecoverFile(int threshold, const char *outFilename, char *const *inFilenames)
730{

Callers 1

CRYPTOPP_API mainFunction · 0.85

Calls 5

IntToStringFunction · 0.85
AddRouteMethod · 0.80
resetMethod · 0.45
PutMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected