added random key generation for registeration.