How to create a random 160 bit prime number in C++? -



How to create a random 160 bit prime number in C++? -

i working on project in school , need create 160 bit value. haven't programmed in while can't figure out how implement this. help appreciated.

you need library big integers (assuming can't take ready-to-use cryptographic library).

first create random 160-bit value, not prime. depending on platform, may utilize /dev/random, cryptgenrandom, or other enthropy source(s), (possible several ones, combined).

then increment value in loop, applying e.g. miller-rabin (pseudo-)primality test each candidate, until find prime number.

c++

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -