You must use the key derivation function , in particular PBKDF2 is the most modern in obtaining an AES key with a password or PIN code.
In particular, PBKDF2 makes it difficult to perform a key search because it:
randomizes the key, so it makes useless precomputer dictionaries of the word
increases the computational cost of testing each candidate, increasing the total time required to search for a key.
As an additional note, I would say that 6 digits correspond to approximately 16 bits of password entropy, which, of course, are too few. Increase the password length.
source
share