Sunday, March 9, 2025

Tabula Recta

Substation cipher encrypt a message by substituting a character with another this mixing up the original message. A polyalphabetic substitution replace the same character by more than 1 alphabets so making it harder to break. Tabula recta uses a matrix of alphabets and a key phrase. To encrypt, the message is aligned with the secret key which is used an index to look up from the aplhabet matrix the corresponding character to substitute with. The key shorter than the message is repeatedly used. Another trick is to expand the key. The key can be an excerpt of text from a book that is as long as the message. 

Saturday, March 8, 2025

Random surfer algorithm

In a search engine, a query will identify a group of pages. The pages are ranked by many factors. One of them is how many hyperlinks reference this page indicating the popularity and thus the relevance. 

Another consideration is if the page linking to the target page is more authoritative than other page pointing to another target page. In other words, not all links are equal weigh.  Computer is not able to discern which referencing page is more authoritative  

The random surfer algorithm use to assign an authoritative score for each page to be further use in the ranking stage. It is simulating a person surfing by following a random link on a page to another page.  He surf a random number of page and then restart the process from the base page again. The random behaviour reduce the effect of loop and also simulating the popularity of a page.


Diffe-Hellman Key Exchange

Each party choose a separate secret number for themselves 

Both parties agreed on a common base number and a modulus.  The modulus must be a large prime number  the base must be a primitive root of the modulus (when the base is raised to a certain power successively, the reminder will cover all numbers within the modulus boundary.   

Each party calculate base raise to the power of their secret number then derive the modulus. Each party send the result to the other. 

Each party raise the reminder from the other party to the power of their secret number. The reminder is calculated and thus become the share secret.  

Friday, March 7, 2025

Search Engine Indexing

Each word on a web page is placed on an index. In addition, the relative position of the word on a page is also stored (for example, first word is 1 and the second word is a 2). 

The word location can be used to support phrase searching (mult-word sequence). It also allow the search engine to estimate the relevance of a page to the query. The closer the distance between words on a page, the more relevant is the page to the query. 

Beside the content, search engine also index html tags to support search for specific part of document like “cat in the title”