简体   繁体   中英

Prediction of the next number generated by C (glibc) rand()

Given a series of numbers generated by rand(), how can I predict the next value? Brute force is out of the question. I'm aware that rand() is basically a linear congruential generator, but also makes bit shifting. What theory can I use to crack it? Any hints will be most welcome :)

@unwind: thanks for the advice! I was wrong in some places, and the documentation got me on the right track.

Actually, predicting is a piece of cake when you know a sequence of 30 (or so) numbers. The 'computed' answer will be right in 50% of cases. More details present in the link provided by unwind, or in a simplified code: http://www.mathstat.dal.ca/~selinger/random/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM