public void Export_Base16_is_default() { var psk = new PreSharedKey().Generate(); var s1 = new StringWriter(); var s2 = new StringWriter(); psk.Export(s1); psk.Export(s2); Assert.AreEqual(s1.ToString(), s2.ToString()); }
public void Export_BadBase() { var psk = new PreSharedKey().Generate(); var s = new StringWriter(); psk.Export(s, "bad"); }
public async Task PrivateNetwork_WithSwarmKeyFile() { using (var ipfs = CreateNode()) { try { var key = new PreSharedKey().Generate(); var path = Path.Combine(ipfs.Options.Repository.ExistingFolder(), "swarm.key"); using (var x = File.CreateText(path)) { key.Export(x); } var swarm = await ipfs.SwarmService; Assert.IsNotNull(swarm.NetworkProtector); } finally { if (Directory.Exists(ipfs.Options.Repository.Folder)) { Directory.Delete(ipfs.Options.Repository.Folder, true); } } } }
public void Export_Base64() { var psk1 = new PreSharedKey().Generate(); var s = new StringWriter(); psk1.Export(s, "base64"); var psk2 = new PreSharedKey(); psk2.Import(new StringReader(s.ToString())); CollectionAssert.AreEqual(psk1.Value, psk2.Value); }