Encryption Question

I have a question about encryption. So I have a code sample that has a key size being chosen, something like 32 bits or something, and I am basically either filling the key size buffer with the password and then zeroes, or null bytes, or a word repeated over and over (Supercalafragalisticexpialidocios). Is there something I am missing about key and IV selection or is this the right way to go? I thought I saw something that automatically chooses the remaining bytes but I don't remember the name of the object. The data security book does not go into this problem at all.