# How does Diffie-Hellman apply to strings?

I have been doing a lot of research on Diffie-Hellman, and I understand how Alice and Bob are able to get a shared g^ab using both of their private keys. However, I am unsure about how this can be applied to passwords (strings). I assume you have to do something with the hex version of both the password and g^ab, but what? Any help would be much appreciated!

• What are you hoping to achieve by using "password strings" instead? Recall that all modern encryption/key agreement algorithms operate on plain binary data for a reason, trying to change that is generally not necessary/not beneficial. – Luke Park Dec 16 '19 at 19:49
• A string can be thought of as a number in base 26 (or base 36 if you include digits). Use D-H to generate a shared number and convert that number to base 26. That can be treated as a string. – rossum Dec 18 '19 at 14:40

Strings are a special case of numbers. Everything computer algorithms operate on are just special cases of numbers. The string "abc" is commonly encoded as 0x616263, but that's just a number (6,382,179). A movie stored in an AVI file can be thought of as just one massive number, with potentially billions of digits. Numbers can be very large. That's not a problem. So there's no algorithmic problem with b being a number that happens to represent any string you like.