« first day (845 days earlier)      last day (4118 days later) » 

11:29 PM
Is this accurate information on building a compiler ? msdn.microsoft.com/en-us/magazine/cc136756.aspx
 
@noob1992 if your a noob why are you building a compiler?
@noob1992 and yes if its on MSDN its accurate. THey are the unquestioned uathroity on programming
@drch You on?
 
ya
 
@drch you said yesterday you could explain gethashcode to me
would you please?
 
sure brb
@JABFreeware do you know how a hashtable works?
internally?
 
@drch no not at all
 
11:43 PM
ok so an object's hashcode is used for 2 things
testing equality and in collections like hashtables
so for hash tables, say i gave you 50 ping pong balls. each had a random word on it, and they were either red green blue yellow or purple and you needed a fast way to search them
so if i was going to randomly ask for a ball with a certain colour and word on it, how would you sort them?
 
@drch by color
 
exactly
so thats what a hashtable will do
it puts them in buckets based on the hashcode
the hashcode is an integer
so if the hashtable internally has 10 buckets, it will calculate the hashcode modulus 10 and put it in that bucket
thats why hashtables have really fast lookups
 
@drch modules 10?
10/10 has no remaineder
 
modulus is like the remainder from division
yeah so that would go into bucket 0
if the hashcode was 17 it would go into bucket 7
 
@drch oh I get it
so its not encryption at all, its basically like getting everything organized for searching
 
11:49 PM
yep
 
@drch Okay, thanks for explaining it all to me!
 
and for equality, hashcodes will collide. two objects that are not equal can have the same hashcode
but if two objects do not have the same hashcode then we know quickly that they are not equal
 
@drch REALY??
how likely is it?
 
well theres only 4 billion values for an int
so pretty likely in the grand scheme of things
 
@drch I see
so let me ask this
 
11:52 PM
yeah dont trip on the 'hash' word
its not the same as a one-way hashing algorithm in cryptography
 
Say, just for an example, that I have a program I want to be machine specific, and so i
get the serial number of the hardrive, and put into a file
naturally I dont want them to look at the file and happen to notice that hey, thats my hardrive serial number
origranlly I just used gethashcode and stored it, but thats not such a good idea after all
how could I do that, so that when the program starts it check the hardrive serial number against the one thats stored and hashed
or encoded somehow
 
sure in that case you could use a hashing algorithm like md5 or sha1
 
@drch oh okay.
I read that a licensing system is only to keep honest users honest
 
those are one-way cryptography algorithms that are extremely unlikely to collide
 
Obviously someone can just reverse compile the program and see how you are doing it and edit out the checking
 
11:56 PM
youre more likely to get the same serial number than the same md5
 
@drch good
@drch yeah, Im not using the hardrive serial number
that was just an example
 
what are you using?
 
@drch thats my secret! :)
 
ha
i think i was looking at this before on SO and they suggested grabbing a few different hardware identifiers and combining them
 
@drch yeah thats what im doing
 
11:58 PM
cool
 
but I woulnt say which ones!!! :)
 
what are you building?
 
@drch a program
 
clearly
 
LOL
@drch its an updated version of
 

« first day (845 days earlier)      last day (4118 days later) »