If your iMac is connected to the wifi, just open the Kechain Access app (it’s in the utilities folder within applications). Go to the “System” keychain, and look through the list to find the name of the network. Double click the entry, and a window will pop up with the details. At the bottom it says “show password”. Click that bubble, it will ask you for an administrator password (should be your login password), and the wifi password will show up! (it might also ask you to type in the password twice). After you’re in the keychain, it should be pretty straightforward!
Cheers!