One convenient way to do it is to hash the password using a fixed length hashing algorithm, such as sha256. I will add exact code later.