Up to Main Index Up to Journal for March, 2014 JOURNAL FOR THURSDAY 20TH MARCH, 2014 ______________________________________________________________________________ SUBJECT: Coding blitz DATE: Thu 20 Mar 23:03:41 GMT 2014 Last night was one of the best coding sessions I'd had in a very, very long time. For over four hours I sat and coded, in the zone and buzzing - coding as it should be. This state was once easy for me to get into, but for months now it's been harder and harder to achieve. I've no idea why, I've just found it hard to focus and difficult to concentrate for long. Burn out? Exhaustion? No idea at all. One of changes I've made - after numerous comments - is to change the way player files are named. Instead of having unwieldy 88 character long names they are now simple 32 character long hexadecimal names. Now instead of file names like: q50jAhbPYlMHH3vX-oWd-knmH2E--6VuF2x…pKOcCkJmjHkNwlOtiNXQEt0SWuwFQVw==.wrj We now have more manageable file names: d8f7fdd51473a76acb842ce61bc96ead.wrj This change basically uses the 16 byte MD5 hash of the account name instead of the 64 byte SHA512 hash that was then Base64 encoded. Does using a weaker, shorter hash actually make a difference? In this particular situation no. The hash is not used in a cryptographic sense, it's used as a unique ID. The only difference it makes is there will be a greater chance of a hash collision[1] when creating a new account. This would cause you to be told that an account is already taken when in fact it isn't - the hash is just the same as an existing one. If anyone wants to change the hashing or encoding of the file names they can. All of the code is in a single HashAccount function for convenience. In fact all of the hashing and encoding for accounts and passwords is in three simple functions instead of being replicated and scattered all over the place. Players in-game are now referenced internally by the account hash instead of the character's name. I've said before that character names should not need to be unique - how many people do you know called Alice or Bob? Player's should be able to differentiate themselves through their clothing, equipment, titles, profession and other means[2]. The recordjar encoder and decoder can now handle more types. I've also noticed some silliness in the PlayerList type that needs to be tidied up - the channel being used as a mutex should actually be passing around the players map instead of a boolean flag. All in all a good evening's coding :) -- Diddymus [1] Chances are 1 in 340,282,366,920,938,463,463,374,607,431,768,211,456 :) [2] Thoughts filed for later: Birthmarks? Tattoos? If you die in combat should there be a probability of you getting a scar? Up to Main Index Up to Journal for March, 2014