MCPcopy Create free account
hub / github.com/Yeuoly/0xUBypass / RandomNumber

Method RandomNumber

WindowsShellcodeInjector/RSA.cpp:116–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116BigUint math::RandomNumber(BigUint min, BigUint max) {
117 const int random_max = 2 << 14;
118 BigUint distance = max - min;
119 if (distance == 0) {
120 return 0;
121 }
122 if (distance < random_max) {
123 return rand() % distance;
124 }
125
126 BigUint result = 0;
127 while (distance >= random_max) {
128 result = result * random_max + rand();
129 distance /= random_max;
130 }
131
132 result += min;
133
134 while (result > max) {
135 result >>= 1;
136 }
137
138 return result;
139}
140
141
142BigUint rsa::GeneratePrime(int bits) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected