improved aes crypt function