I am writing a small personal project where I would like to use AES to encrypt some documents. It seems to work pretty well, but I was wondering about one point of my code. The current structure is
user inputs password ->
key = sha256(password) ->
AES(document, key). Where compress XORs the key with itself. So for 128 bit AES the first half is XORed with the second to get a 128bit key. I do a similar operation for 192 bit AES. I have a few questions about this:
- Is it safe? If not, could I just drop the extra bits?
- Is there a better way to go from a password to a key? I think for the average password entropy is pretty low.
- Could I use this method to generate an IV for some other block cipher mode?