So i was doing the 2019 picoCTF binary challenge seed-sPRiNG where i got this write up with this code:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main ()
{
int i;
srand(time(0));
for (i = 0; i < 30; i++)
{
printf("%d\n", rand() & 0xf);
}
return 0;
}
So i thought of implementing the same in python. At first i used the random module but realized the C rand and pythons are miles apart in their implementation so i decided to use ctypes:
#!/usr/bin/python3
from ctypes import CDLL
libc = CDLL("libc.so.6")
libc.srand(libc.time(0))
for i in range(30):
print(libc.rand() % 0xf)
But i still get different output when i run them both, Can i get an explanation why this is so