Ensure that the password is terminated with zero

And ensure that we can handle all password lengths