I am trying to implement Diffie–Hellman key exchange in C++ based on Crypto++ library (https://www.cryptopp.com/wiki/Diffie-Hellman).
The other side of the key agreement can be implemented in any language such as Java. Base64 is the common format to both sides.
This is my code snippet:
DH dh;
dh.AccessGroupParameters().Initialize(p, g);
SecByteBlock privKey(dh.PrivateKeyLength());
SecByteBlock pubKey(dh.PublicKeyLength());
dh.GenerateKeyPair(rnd, privKey, pubKey);
How can I encode the public key to Base64?