# Work out an algorithm

I'm wanting to work out the algorithm what gives these results

It's always a $6$ digit code that is turned into a $4$ digit code

$000000$ is $1558$

$000001$ is $9617$

$000002$ is $8633$

$000010$ is $2882$

etc...

I have a program that can give me the $4$ digit code for any $6$ digit code but I would like to work out the maths behind it if possible.

Where should I start trying to figure it out? Are there any 'common' things I could do/read up on to help me figure this out?

• Too many possibility. There are hundred of hash functions, so many pseudorandom generator, and who know what else; and each can come with parameters too. You need more context to help. It might be better to just list out all the possibilities since there isn't a lot. – Gina Jan 6 '14 at 13:05
• Ahh okay. Basically it's to work out the radio code for cars. The 6 digit code is the serial number and the 4 digit code is the unlock code. I've seen many sites and programs what will work it out for you for a price, I wanted to provide a free alternative, but it seems it might be way too much work figuring out the method used. – TMH Jan 6 '14 at 13:08
• @Gina How is one million different possible inputs "not a lot"? But yes, it's not impossible (at least mathematically) that your conputer in effect just has a table with a million (possibly random) entries with a corresponding four-digit code. Which means that even if we knew all but one of them, we might not have the slightest shot at guessing the last one. Even if there were an actual calculation behind it, the whole point of a good hashing algorithm is that it should be very difficult to break even when you know a lot of input-output pairs. – Arthur Jan 6 '14 at 13:10
• Can you show us the program you have? (Post it to a paste bin.) – lhf Jan 6 '14 at 13:16
• @Arthur: it will took like, at most 10MB to store it. If mathematicians can compute matrices of the monster group taking in the order of gigabytes, surely we can spend 10MB? It sounds like he have a program on his hand, so it's not like it take any significant resource to acquire 1 result. And you can always write a program to automate the process. – Gina Jan 6 '14 at 13:16

## 2 Answers

Try this NIST Standard: http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf It uses DRBG and elliptic curves.

If you can find sites that perform the translation, this means that the coding formula is an official standard or somehow published.

Otherwise, it may be that those sites are hosted or permitted by the radio manufacturer(s) and chances are high that cracking the cipher for third parties is illegal.

This said, I wouldn't expect the hashing formula to be sophisticated, and rather home-made (possibly just a linear congruential generator). Reverse engineering it from just four values is pretty illusory.

The first thing to be tried is to collect sufficiently many pairs (Serial, Code), say one hundred, and plot them. If you are lucky a pattern will emerge.