/// <summary> /// Generates given number of packages in the path. Wipes the target path /// </summary> /// <param name="count"></param> public void CreatePackages(int count, int maxFiles, int maxFileSize, string path) { if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); List <string> packages = new List <string>(); TRandom random = new TRandom(); for (int i = 0; i < count; i++) { List <PackageCreateItem> files = new List <PackageCreateItem>(); int filesToAdd = random.Next(0, maxFiles); for (int j = 0; j < filesToAdd; j++) { byte[] buffer = new byte[maxFileSize]; random.NextBytes(buffer); Stream file = new MemoryStream(buffer); files.Add(new PackageCreateItem(file, $"folder{Guid.NewGuid()}/{Guid.NewGuid()}")); } PackageCreateArguments package = new PackageCreateArguments { Id = Guid.NewGuid().ToString(), Files = files }; _packageServices.CreatePackage(package); Console.WriteLine($"Generated package {package.Id}"); } }
public static ByteString GenerateNewHash() { var hashBytes = new byte[16]; TRandomDevice.NextBytes(hashBytes); return(ByteString.CopyFrom(hashBytes)); }
public void GenerateNewHash() { var hashBytes = new byte[16]; TRandomDevice.NextBytes(hashBytes); _sessionHash = ByteString.CopyFrom(hashBytes); }
public void NextBytes() { var buffer = new byte[32]; TRandom.NextBytes(buffer); foreach (var value in buffer) { if (value != 0) { return; } } Assert.Fail("Empty byte buffer"); }