Saturday, March 8, 2008

Cows and bulls practical

The correct guess to try in the practical version of cows and bulls encrypted is 6598. the number of cows and bulls are displayed in the alert box. The logic is simple....the RSA public key cryptography is used with a preset key of 17 and 3233. The example is taken right out of wikipedia. The guesses that are entered are taken and there position is appended to it(i.e, 1,2,3 and 4). This value is then encrypted and compared with the values stored in arrays 'a' and 'b', a has the values that are bulls and b has all the cows. The values are given below:
bulls
64-1577
53-652
92-2762
81-1485
cows
63-2909
62-1162
61-178
54-1978
52-3094
51-2985
94-205
93-456
91-3157
84-1820
83-3185
82-2661
The game in practicallity would have to have more number of such encrypted arrays. One of them would have to be choosen randomly. However, the randomess doesnt need to be hidden.If a higher degree of encryption is needed, the keys can be changed and the arrays and the function that is used to encrypt can be changed at the server side when the javascript is generated.

No comments: