How to convert a Diffie–Hellman key exchange number to work with different encryption algorithms I just read about Diffie–Hellman key exchange and was wondering how the value created from that can be used for any encryption method.  Here is a link of where I read it from.
As the output of the DH key exchange is a number, it has to be converted into big-endian bytes before running it through a hash - say SHA (SHA2 or SHA3) for example, can convert it into a key of the correct length.

If you need variable-length keys, then you can use XOFs, which provide variable length outputs. This cannot increase the entropy of the result of the DH exchange.

If you need multiple keys, HKDF is an option. The DH output is already of enough entropy, so you can skip the HKDF-Extract step, and use the HKDF-Expand to create multiple keys that cannot be derived from each other.