<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-5%3Adcho040</id>
	<title>SE250:lab-5:dcho040 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-5%3Adcho040"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-5:dcho040&amp;action=history"/>
	<updated>2026-04-29T04:45:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-5:dcho040&amp;diff=6459&amp;oldid=prev</id>
		<title>Mark: 12 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-5:dcho040&amp;diff=6459&amp;oldid=prev"/>
		<updated>2008-11-03T05:19:45Z</updated>

		<summary type="html">&lt;p&gt;12 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Understanding the codes==&lt;br /&gt;
&lt;br /&gt;
===buzhash.c===&lt;br /&gt;
&lt;br /&gt;
====Satic Values====&lt;br /&gt;
 hash_t(unsigned long) BUZINIT&lt;br /&gt;
 hash_t(unsigned long) buztbl[256]&lt;br /&gt;
 &lt;br /&gt;
====void random_perm( int *C)====&lt;br /&gt;
 input : 256 int array&lt;br /&gt;
 work : Random changing between values in the array&lt;br /&gt;
 output : No&lt;br /&gt;
 used in ressed_buztable&lt;br /&gt;
 &lt;br /&gt;
====void ressed_buztable====&lt;br /&gt;
 input : No&lt;br /&gt;
 work : Change the values(BUZINIT, buztbl[256]) to random&lt;br /&gt;
 output : No&lt;br /&gt;
&lt;br /&gt;
*test&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====How it works=====&lt;br /&gt;
e.g. changing of the value BUZINIT&lt;br /&gt;
&lt;br /&gt;
C[0] = 1&lt;br /&gt;
Before&lt;br /&gt;
BUZINIT = D4A96F89&lt;br /&gt;
11010100 10101001 01101111 10001001 &lt;br /&gt;
&lt;br /&gt;
BUZINIT = NUZINIT &amp;lt;&amp;lt; 1 | C[0]&lt;br /&gt;
&lt;br /&gt;
After&lt;br /&gt;
BUZINIT = A952DF13&lt;br /&gt;
10101001 01010010 11011111 00010011 &lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
C[0] = 0&lt;br /&gt;
&lt;br /&gt;
Before&lt;br /&gt;
BUZINIT = A952DF13&lt;br /&gt;
10101001 01010010 11011111 00010011 &lt;br /&gt;
&lt;br /&gt;
BUZINIT = NUZINIT &amp;lt;&amp;lt; 1 | C[0]&lt;br /&gt;
&lt;br /&gt;
After&lt;br /&gt;
BUZINIT = 52A5BE26&lt;br /&gt;
01010010 10100101 10111110 00100110 &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------&lt;br /&gt;
... 256 times with random C[0] = (0 or 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== to get binary information=====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Use this function&lt;br /&gt;
void bits(unsigned long a) {&lt;br /&gt;
	unsigned long displayMask = 1 &amp;lt;&amp;lt; 31;&lt;br /&gt;
	int c;&lt;br /&gt;
	for (c = 1; c &amp;lt;= 32; c++) {&lt;br /&gt;
		putchar( a &amp;amp; displayMask ? &amp;#039;1&amp;#039; : &amp;#039;0&amp;#039; );&lt;br /&gt;
		a = a &amp;lt;&amp;lt; 1;&lt;br /&gt;
		if ( c%8 == 0) {&lt;br /&gt;
			putchar(&amp;#039; &amp;#039;);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	putchar(&amp;#039;\n&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====How to use &amp;amp;, |, &amp;lt;&amp;lt;, &amp;gt;&amp;gt;=====&lt;br /&gt;
*e.g. How it works? a = a&amp;lt;&amp;lt;2 | 3;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1) the initial value of &amp;#039;a&amp;#039;&lt;br /&gt;
6A54B7C4 (01101010 01010100 10110111 11000100)&lt;br /&gt;
&lt;br /&gt;
2) a &amp;lt;&amp;lt; 2 is run&lt;br /&gt;
6A54B7C4 (01101010 01010100 10110111 11000100) to&lt;br /&gt;
A952DF10 (10101001 01010010 11011111 00010000) &lt;br /&gt;
&lt;br /&gt;
3) a | 3 is run&lt;br /&gt;
a      = A952DF10 (10101001 01010010 11011111 00010000) &lt;br /&gt;
3      =                    3 (00000000 00000000 00000000 00000011)&lt;br /&gt;
a | 3 = A952DF13 (10101001 01010010 11011111 00010011)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====void dump_buztbl====&lt;br /&gt;
 input : No&lt;br /&gt;
 work : print BUZINIT and buztbl[]&lt;br /&gt;
 output : No&lt;br /&gt;
 &lt;br /&gt;
====hash_t buzhash( char * key )====&lt;br /&gt;
 input : char *key =&amp;gt; char array (e.g. &amp;quot;bbbbbbb0&amp;quot;)&lt;br /&gt;
 work : No&lt;br /&gt;
 output : hash h (explain below)&lt;br /&gt;
 &lt;br /&gt;
=====How to return value(hash h)=====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
e.g. char *key =&amp;gt; &amp;quot;abcdef0&amp;quot;&lt;br /&gt;
         BUZINIT = 1783936964L&lt;br /&gt;
         buztbl[97] = 11100011 10011101 11100101 10000010(base2)&lt;br /&gt;
 &lt;br /&gt;
hast_t h = BUZINIT // h = 1783936964&lt;br /&gt;
while ( *key )             // a -&amp;gt; b -&amp;gt; c -&amp;gt; d -&amp;gt; e&lt;br /&gt;
 &lt;br /&gt;
   h = ((h &amp;lt;&amp;lt; 1) | (h &amp;gt;&amp;gt; (sizeof(hash_t)*8-1))) ^ buztbl[ (unsigned)*key++ ]; //*key = a&lt;br /&gt;
	   // h = 01101010 01010100 10110111 11000100&lt;br /&gt;
	   // ((h &amp;lt;&amp;lt; 1) | (h &amp;gt;&amp;gt; (sizeof(hash_t)*8-1)))&lt;br /&gt;
		// &amp;#039;0&amp;#039;1101010 01010100 10110111 11000100 move first value &amp;#039;0&amp;#039;&lt;br /&gt;
		//     11010100 10101001 01101111 1000100&amp;#039;0&amp;#039;     to the end&lt;br /&gt;
	   //buztbl[ (unsigned)*key++ ] //buztbl[97]     ( 97=&amp;#039;a&amp;#039; )&lt;br /&gt;
		//11100011 10011101 11100101 10000010&lt;br /&gt;
	   //       11010100 10101001 01101111 10001000 ^ (xor)&lt;br /&gt;
	   //       11100011 10011101 11100101 10000010&lt;br /&gt;
	   // h = 00110111 00110100 10001010 00001010(base2)&lt;br /&gt;
   h = ((h &amp;lt;&amp;lt; 1) | (h &amp;gt;&amp;gt; (sizeof(hash_t)*8-1))) ^ buztbl[ (unsigned)*key++ ]; //*key = b&lt;br /&gt;
   h = ((h &amp;lt;&amp;lt; 1) | (h &amp;gt;&amp;gt; (sizeof(hash_t)*8-1))) ^ buztbl[ (unsigned)*key++ ]; //*key = c&lt;br /&gt;
   h = ((h &amp;lt;&amp;lt; 1) | (h &amp;gt;&amp;gt; (sizeof(hash_t)*8-1))) ^ buztbl[ (unsigned)*key++ ]; //*key = d&lt;br /&gt;
   h = ((h &amp;lt;&amp;lt; 1) | (h &amp;gt;&amp;gt; (sizeof(hash_t)*8-1))) ^ buztbl[ (unsigned)*key++ ]; //*key = e&lt;br /&gt;
   &lt;br /&gt;
return h;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====hash_t buzhashn( char * key, int n )====&lt;br /&gt;
 input : char *key =&amp;gt; char array (e.g. &amp;quot;bbbbbbb0&amp;quot;)&lt;br /&gt;
              int n                                      (e.g. 3)&lt;br /&gt;
 work : No&lt;br /&gt;
 output : hash h (same as buzhash but use only use n values from *key)&lt;br /&gt;
&lt;br /&gt;
=====Keep editing=====&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>