public void TestCreateKeyPair() { byte[] privateKey = new byte[32]; //NaCl.SECRETKEYBYTES byte[] publicKey = new byte[32]; //NaCl.PUBLICKEYBYTES CryptTool.GenerateKeyPair(ref privateKey, ref publicKey); Assert.IsFalse(privateKey.SequenceEqual(new byte[32]), "empty private key"); Assert.IsFalse(publicKey.SequenceEqual(new byte[32]), "empty public key"); }
protected override void Execute() { byte[] privateKey = new byte[32]; //NaCl.SECRETKEYBYTES byte[] publicKey = new byte[32]; //NaCl.PUBLICKEYBYTES CryptTool.GenerateKeyPair(ref privateKey, ref publicKey); // Write both keys to file DataUtils.WriteKeyFile(this.privateKeyPath.Value, new Key(Key.KeyType.PRIVATE, privateKey)); DataUtils.WriteKeyFile(this.publicKeyPath.Value, new Key(Key.KeyType.PUBLIC, publicKey)); }
/// <summary> /// Wrapper to generate key pair <see cref="Threema.MsgApi.CryptTool.GenerateKeyPair"/> /// </summary> /// <param name="privateKeyPath">Full path name of private key file</param> /// <param name="publicKeyPath">Full path name of public key file</param> public void GenerateKeyPair(string privateKeyPath, string publicKeyPath) { byte[] privateKey = new byte[32]; //NaCl.SECRETKEYBYTES byte[] publicKey = new byte[32]; //NaCl.PUBLICKEYBYTES CryptTool.GenerateKeyPair(ref privateKey, ref publicKey); // Write both keys to file DataUtils.WriteKeyFile(privateKeyPath, new Key(Key.KeyType.PRIVATE, privateKey)); DataUtils.WriteKeyFile(publicKeyPath, new Key(Key.KeyType.PUBLIC, publicKey)); }