0

So I am trying to do the following:

1) $session_key => randomly generated AES key

2) encrypt $data => using AES encryption using $session_key and $data

3) I skipped some steps in between this to actually make it a secure form of encryption, but obviously, use $session_key to decrypt the data

I am having trouble figuring out how to randomly generate a secure key to to encrypt the data with.

Can anyone help?

bryan
  • 8,879
  • 18
  • 83
  • 166
  • Does your question actually boil down to "how to generate a random, like, *really random* string"? – deceze Jul 17 '14 at 15:13
  • I guess. I really wanted to generate a random 256-bit AES key which I guess I need some sort of random value to encrypt it? @deceze – bryan Jul 17 '14 at 15:14

1 Answers1

5

openssl_random_pseudo_bytes() is really secure and easy to use.

Hamid Alaei
  • 406
  • 4
  • 16