refactored javascript to use a better loop structure
added max length
added encryption and decryption of the password