| 700 | } |
| 701 | |
| 702 | void 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 | |
| 729 | void InformationRecoverFile(int threshold, const char *outFilename, char *const *inFilenames) |
| 730 | { |
no test coverage detected