I require a funtion that creates a pseudo random 6 decimal digit pincode using the date as a seed. A maximum of 1000 codes should be valid for any one day meaning the chance of guessing the correct code is 1 in 1000. It should not be possible to generate the same code twice on the same day. The date seed should be the current date as the code should only be valid for the current day. When decoded and validated against the date, the code should contain information pertaining to a size (small, medium or large).
The code generator should be written in Delphi and the decoder to be written in C as it will be decoded on a microcontroller.