Does the secret key used in AES have to prime?
No, it does not have to be a prime. 

All you need is an appropriately long and random key:


AES-128 = expects key-length of 16 raw/binary bytes (= 128 / 8 bits per byte)
AES-192 = expects key-length of 24 raw/binary bytes (= 192 / 8 bits per byte)
AES-256 = expects key-length of 32 raw/binary bytes (= 256 / 8 bits per byte) 


As a practical example, you could use a hashing function like sha-2 to generate a key from a random password, or from a Diffie-Hellman session key, or from an RSA session key, etc. Of course, if it does not conflict your individual purposes, you would be advised to use a deliberately slow key derivation function such as pbkdf-2, bcrypt, or scrypt together with a random salt instead of SHA-2… but let’s stick with SHA-2 to keep it easy.

Depending on the implementation, SHA-2 will return either raw binary bytes, or – more likely – a hex string representing those raw binary bytes. AES-256 for example takes a 32 byte key, which corresponds to 64 characters in hex encoding. All you need to do is to use those bytes SHA-256 returned as a key for AES-256 and you’re set. 

In pseudo-code, it would go something like this:

plaintext = "This is top secret!"
key = sha256("This is the password.")
iv = cryptographically_secure_rng();
ciphertext = aes256(plaintext, key, iv);