Change message id generation

Use hexadecimal digest and truncate at 64 characters.
Limit the number of iterations to find an available message_id.