OVH Cloud OVH Cloud

gene de hasard

10 réponses
Avatar
remy
bonjour

l'idee de base consiste a faire la difference entre deux nb premier
j'aimerais bien avoir votre avis sur cette idee deja connue peut etre ?
pour les nb impairs une concatenation et l'on retaille a 8 bits
devrait aussi peut etre faire l'affaire java n'est pas vraiment adapte :(
merci remy


code java

import java.util.*;
import java.lang.*;
import java.math.*;

public class gene
{
public static void main(String args[])
{
if(args.length!=1)
{
System.out.println("generateur ");
System.out.println(" java gene nb_premier " );
System.out.println(" ex :java gene 3623 ");
return;
}
String strp=args[0];

BigInteger p=new BigInteger(strp);
BigInteger tmp_p=p;
BigInteger res;
BigInteger pow=new BigInteger("2");
int n=p.toString(2).length();
pow=pow.pow(n);

if(! p.isProbablePrime(100))
{
System.out.println(p+ " n'est pas un nb premier");

return;
}



while (true)
{
p=p.add(pow);
if(p.isProbablePrime(100))
{
res=p.subtract(tmp_p);
if(res.toString(2).length()<32)
{
System.out.print(res +" ");
}
else
{
System.out.println("ca arrive ");
}
tmp_p=p;
n=p.toString(2).length();
if (n>100){n=1;}
pow=new BigInteger("2");
pow=pow.pow(n);
}
}
}
}

10 réponses

Avatar
remy
une petit erreur dans le code
ca va plus vite et plus ""alelatoire""


import java.util.*;
import java.lang.*;
import java.math.*;

public class gene
{
public static void main(String args[])
{
if(args.length!=1)
{
System.out.println("generateur ");
System.out.println(" java gene nb_premier " );
System.out.println(" ex :java gene 7 ");
return;
}
String strp=args[0];

BigInteger p=new BigInteger(strp);
BigInteger tmp_p=p;
BigInteger res;
BigInteger pow=new BigInteger("2");
int n=p.toString(2).length();
pow=pow.pow(n);
boolean búlse;
if(! p.isProbablePrime(100))
{
System.out.println(p+ " n'est pas un nb premier");
return;
}



while (true)
{
p=p.add(pow);
if(p.isProbablePrime(100))
{
res=p.subtract(tmp_p);
if (b)System.out.print(res+" ");
tmp_p=p;
if (n>100){n=1;b=true;}
pow=new BigInteger("2");
pow=pow.pow(n);
}
n++;
}
}
}
Avatar
remy
bonjour

une dernnier Maj avec un petit bia sur le chifre 1
si vous avez une idee je suis toujour preneur

import java.util.*;
import java.lang.*;
import java.math.*;

public class gene
{ static int tab[]={0,0,0,0,0,0,0,0,0,0};

public static void main(String args[])
{
if(args.length!=4)
{
System.out.println(" java gene cle_n0 cle_n1 cle_n2 qtDeNb " );
System.out.println(" cle_n0 = nb premier ");
System.out.println(" cle_n1 = nb de bit max des nb premier ");
System.out.println(" cle_n2 = puissance max de l'ecard entre deux nb
premier ");
System.out.println(" qtDeNb =nombre de tirage ");
System.out.println(" ex :java gene 3623 100 200 1000 ");
return;
}
BigInteger p=new BigInteger(args[0]);
if(! p.isProbablePrime(100))
{
System.out.println(p+ " n'est pas un nb premier"); return;
}
int taille=Integer.parseInt(args[1]);
int ecart=Integer.parseInt(args[2]);
int qt=Integer.parseInt(args[3]);

System.out.println("init ");
p=newGraine(p,taille);
System.out.println("debut ");
allea(p,ecart,qt);
affiche();
}

public static void allea(BigInteger p,int val, int qt)
{
BigInteger res ,tmp_p=p;
BigInteger pow=new BigInteger("2");
BigInteger on=new BigInteger("1");
boolean stop=true,impaire=true;
int nb=0,n=0;

while (stop)
{
p=p.add(pow);
if(p.isProbablePrime(100))
{
nb++;
res=p.subtract(tmp_p);
if(impaire)
{
res=res.subtract(on);
System.out.print(res+" ");
cteFreq(res.toString());
impaireúlse;
}
else
{
System.out.print(res+" ");
cteFreq(res.toString());
impaire=true;
}
cteFreq(res.toString());
tmp_p=p;
if (n>val){n=1;}
if(nb>qt){stopúlse;}
pow=new BigInteger("2");
pow=pow.pow(n);

}
n++;
}
//System.out.println("taille "+p.toString(2).length());
}
public static void affiche()
{
System.out.println();
System.out.println("*********** frequence *************");
for (int i=0;i<tab.length;i++)
{

System.out.print(tab[i]+" ");

}
System.out.println();
}
public static void cteFreq(String s)
{
for (int i=0;i<s.length();i++)
{
switch(s.charAt(i))
{
case '0':
tab[0]++;
break;
case '1':
tab[1]++;
break;
case '2':
tab[2]++;
break;
case '3':
tab[3]++;
break;
case '4':
tab[4]++;
break;
case '5':
tab[5]++;
break;
case '6':
tab[6]++;
break;
case '7':
tab[7]++;
break;
case '8':
tab[8]++;
break;
case '9':
tab[9]++;
break;
}
}
}
public static BigInteger newGraine(BigInteger p,int taille )
{
BigInteger pow=new BigInteger("2");
int n =p.toString(2).length();
pow=pow.pow(n);
while (p.toString(2).length()<taille)
{
p=p.add(pow);

if(p.isProbablePrime(100))
{
System.out.print(".");
n=p.toString(2).length();
pow=new BigInteger("2");
pow=pow.pow(n);
}
}
System.out.println();
return p;
}
}
Avatar
Kevin Drapel
une dernnier Maj avec un petit bia sur le chifre 1
si vous avez une idee je suis toujour preneur


Je ne sais pas si c'est très rapide comme générateur. Pour fixer son
degré d'aléa, il faudrait lui faire passer des tests statistiques.

http://csrc.nist.gov/rng/
http://random.com.hr/products/random/manual/html/Diehard.html

Avatar
remy
"Kevin Drapel" a écrit dans le message de
news:425bb575$
une dernnier Maj avec un petit bia sur le chifre 1
si vous avez une idee je suis toujour preneur


Je ne sais pas si c'est très rapide comme générateur. Pour fixer son
degré d'aléa, il faudrait lui faire passer des tests statistiques.

http://csrc.nist.gov/rng/
http://random.com.hr/products/random/manual/html/Diehard.html


merci

sympa les liens j'en ai au moins pour 6 mois a coder tous les tests
a la vitesse ou j'avance cela va m'occuper un peu les doigts
mais il y a un biais lie a l'idee :-(
la difference de 2 nb premier ne peut faire qu'un nb pair
j'ai modifie un peu la fct
en gros je fais +1 et -1 histoire d'etre honnete mais cela
ne change pas grand chose

par contre j'ai de superbe ecart entre 2 inits "graines" differentes
ce qui me fait un peu plaisir

code modifie de la fct
a+ remy

public static void allea(BigInteger p,int val, int qt)
{
BigInteger res ,tmp_p=p;
BigInteger pow=new BigInteger("2");
BigInteger on=new BigInteger("1");
boolean stop=true,impaire=true,plus=true;
int nb=0,n=0;

while (stop)
{
p=p.add(pow);
if(p.isProbablePrime(100))
{
nb++;
res=p.subtract(tmp_p);
if(impaire)
{
if(plus)
{
res=res.add(on);
plusúlse;
}
else
{
res=res.subtract(on);
plus=true;

}
System.out.print(res+" ");
cteFreq(res.toString());
impaireúlse;
}
else
{
System.out.print(res+" ");
cteFreq(res.toString());
impaire=true;
}
cteFreq(res.toString());
tmp_p=p;
if (n>val){n=1;}
if(nb>qt){stopúlse;}
pow=new BigInteger("2");
pow=pow.pow(n);

}
n++;
}
//System.out.println("taille "+p.toString(2).length());
}


Avatar
remy

sympa les liens j'en ai au moins pour 6 mois a coder tous les tests
a la vitesse ou j'avance cela va m'occuper un peu les doigts
mais il y a un biais lie a l'idee :-(


donc retravailler l'idee, elementaire comme dirait l'autre ...
il suffit de faire la somme des chiffres de la difference des deux nb
premiers
mod(2) avec ou sans la cuisine pour les nb impairs
a tester
si le code vous interesse je vous le posterai des qu'il sera fait

je fais une pause

remy

Avatar
Guillermito
In article <425bc0ac$0$25024$,
says...

sympa les liens j'en ai au moins pour 6 mois a coder tous les tests


Pas la peine, il est assez facile de trouver le code, voire même les
binaires pour plusieurs tests statistiques destinés aux PRNG.

http://www.fourmilab.ch/random/
http://burtleburtle.net/bob/rand/testsfor.html
http://sourceforge.net/projects/randtest/
http://csrc.nist.gov/rng/rng2.html
...

--
Guillermito
http://www.guillermito2.net

Avatar
remy
merci

mais je n'en suis pas encore la
je cherche a regler mon pb de repartition

mais il y a comme un truc qui m'echappe
sans la cuisine pour creer des nb impairs
j'ai une meilleure repartition de 0 /1
quand je fais la somme des chiffres de la difference mod 2

java gene 3623 100 150 1000

etonnant ....
parce qu'il me manque quand meme la moitie des nombres


import java.util.*;
import java.lang.*;
import java.math.*;

public class gene
{ static int tab[]={0,0,0,0,0,0,0,0,0,0};
static int nb0=0,nb1=0;

public static void main(String args[])
{
if(args.length!=4)
{
System.out.println(" java gene cle_n0 cle_n1 cle_n2 qtDeNb " );
System.out.println(" cle_n0 = nb premier ");
System.out.println(" cle_n1 = nb de bit max des nb premier ");
System.out.println(" cle_n2 = puissance max de l'ecart entre deux nb
premier ");
System.out.println(" qtDeNb =nombre de tirage ");
System.out.println(" ex :java gene 3623 100 200 1000 ");
return;
}
BigInteger p=new BigInteger(args[0]);
if(! p.isProbablePrime(100))
{
System.out.println(p+ " n'est pas un nb premier"); return;
}
int taille=Integer.parseInt(args[1]);
int ecart=Integer.parseInt(args[2]);
int qt=Integer.parseInt(args[3]);

System.out.println("init ");
p=newGraine(p,taille);
System.out.println("debut ");
allea(p,ecart,qt);
affiche2();
}

public static void allea(BigInteger p,int val, int qt)
{
BigInteger res ,tmp_p=p;
BigInteger pow=new BigInteger("2");
BigInteger on=new BigInteger("1");
boolean stop=true,impaire=true,plus=true;
int nb=0,n=0;

while (stop)
{
p=p.add(pow);
if(p.isProbablePrime(100))
{
nb++;
res=p.subtract(tmp_p);
/*
if(impaire)
{
if(plus)
{
res=res.add(on);
plusúlse;
}
else
{
res=res.subtract(on);
plus=true;

}
impaireúlse;
}
else
{
impaire=true;
}
*/
System.out.println(res+" ");
Mod(res.toString());
tmp_p=p;
if (n>val){n=1;}
if(nb>qt){stopúlse;}
pow=new BigInteger("2");
pow=pow.pow(n);

}
n++;
}
System.out.println("taille "+p.toString(2).length());
}
public static void affiche2()
{
System.out.println("*********** frequence 0 1 *************");
System.out.println(nb0+" "+nb1);
}
public static BigInteger newGraine(BigInteger p,int taille )
{
BigInteger pow=new BigInteger("2");
int n =p.toString(2).length();
pow=pow.pow(n);
while (p.toString(2).length()<taille)
{
p=p.add(pow);

if(p.isProbablePrime(100))
{
System.out.print(".");
n=p.toString(2).length();
pow=new BigInteger("2");
pow=pow.pow(n);
}
}
System.out.println();
return p;
}

public static void Mod(String p)
{
int val=0;
for (int i=0;i<p.length();i++)
{
val=val+Character.getNumericValue(p.charAt(i));
}
if(val%2==0)
{
nb0++;
}
else
{
nb1++;
}
}



}
Avatar
remy
bonjour

hier soir j'ai fait tourner le code
en gros l'algo

un nb premier "la graine"
on le fait "pousser" jusqu'a la taille voulue
puis l'on fait la difference entre 2 nb premiers en fct d'un ecart
plus ou moins defini "voir la variable n dans le code"
et l'on fait la somme des chiffres modulo 2 de la difference
ce qui donne un bit en sortie

defaut

vitesse pas vraiment rapide
toujours un ecart entre les 1 et 0 avec ou sans cuisine
pour les nb impairs

avantage
enorme difference entre 2 graines differentes
si l'attaquant recupere un morceau de l'alea
il ne pourra pas en faire grand chose a mon avis
et pour l'instant aucune detection de cycle
sur un echantillon de 10000 octets de 8 bits
si mon code et bon

pour le reste cela attendra 15 jours je ne vais pas avoir le temps
remy
Avatar
remy
donc avec ent
vous en penser quoi ?? en gros
remy


Entropy = 7.997036 bits per byte.

Optimum compression would reduce the size
of this 129499 byte file by 0 percent.

Chi square distribution for 129499 samples is 536.80, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bytes is 129.2095 (127.5 = random).
Monte Carlo value for Pi is 3.100773757 (error 1.30 percent).
Serial correlation coefficient is 0.000181 (totally uncorrelated = 0.0).
Value Char Occurrences Fraction
0 499 0.003853
1 487 0.003761
2 514 0.003969
3 464 0.003583
4 499 0.003853
5 467 0.003606
6 489 0.003776
7 496 0.003830
8 467 0.003606
9 542 0.004185
10 470 0.003629
11 499 0.003853
12 512 0.003954
13 523 0.004039
14 502 0.003876
15 539 0.004162
16 486 0.003753
17 458 0.003537
18 476 0.003676
19 510 0.003938
20 502 0.003876
21 484 0.003737
22 453 0.003498
23 490 0.003784
24 468 0.003614
25 466 0.003598
26 502 0.003876
27 508 0.003923
28 519 0.004008
29 508 0.003923
30 523 0.004039
31 531 0.004100
32 512 0.003954
33 ! 494 0.003815
34 " 475 0.003668
35 # 511 0.003946
36 $ 461 0.003560
37 % 454 0.003506
38 & 509 0.003931
39 ' 478 0.003691
40 ( 489 0.003776
41 ) 464 0.003583
42 * 482 0.003722
43 + 504 0.003892
44 , 473 0.003653
45 - 501 0.003869
46 . 523 0.004039
47 / 498 0.003846
48 0 497 0.003838
49 1 451 0.003483
50 2 468 0.003614
51 3 536 0.004139
52 4 453 0.003498
53 5 476 0.003676
54 6 480 0.003707
55 7 541 0.004178
56 8 489 0.003776
57 9 484 0.003737
58 : 536 0.004139
59 ; 489 0.003776
60 < 515 0.003977
61 = 506 0.003907
62 > 537 0.004147
63 ? 576 0.004448
64 @ 478 0.003691
65 A 468 0.003614
66 B 488 0.003768
67 C 485 0.003745
68 D 481 0.003714
69 E 520 0.004015
70 F 480 0.003707
71 G 502 0.003876
72 H 444 0.003429
73 I 493 0.003807
74 J 490 0.003784
75 K 489 0.003776
76 L 461 0.003560
77 M 488 0.003768
78 N 527 0.004070
79 O 513 0.003961
80 P 498 0.003846
81 Q 486 0.003753
82 R 431 0.003328
83 S 526 0.004062
84 T 492 0.003799
85 U 475 0.003668
86 V 517 0.003992
87 W 539 0.004162
88 X 495 0.003822
89 Y 499 0.003853
90 Z 516 0.003985
91 [ 439 0.003390
92 468 0.003614
93 ] 496 0.003830
94 ^ 497 0.003838
95 _ 521 0.004023
96 ` 515 0.003977
97 a 515 0.003977
98 b 460 0.003552
99 c 529 0.004085
100 d 474 0.003660
101 e 478 0.003691
102 f 483 0.003730
103 g 476 0.003676
104 h 451 0.003483
105 i 474 0.003660
106 j 458 0.003537
107 k 518 0.004000
108 l 482 0.003722
109 m 542 0.004185
110 n 523 0.004039
111 o 552 0.004263
112 p 485 0.003745
113 q 475 0.003668
114 r 547 0.004224
115 s 575 0.004440
116 t 500 0.003861
117 u 498 0.003846
118 v 535 0.004131
119 w 576 0.004448
120 x 504 0.003892
121 y 518 0.004000
122 z 561 0.004332
123 { 491 0.003792
124 | 517 0.003992
125 } 538 0.004154
126 ~ 536 0.004139
127 582 0.004494
128 500 0.003861
129 522 0.004031
130 446 0.003444
131 514 0.003969
132 486 0.003753
133 494 0.003815
134 501 0.003869
135 537 0.004147
136 493 0.003807
137 486 0.003753
138 488 0.003768
139 529 0.004085
140 447 0.003452
141 478 0.003691
142 539 0.004162
143 587 0.004533
144 442 0.003413
145 501 0.003869
146 515 0.003977
147 468 0.003614
148 472 0.003645
149 498 0.003846
150 458 0.003537
151 515 0.003977
152 503 0.003884
153 492 0.003799
154 508 0.003923
155 562 0.004340
156 517 0.003992
157 524 0.004046
158 535 0.004131
159 581 0.004487
160 485 0.003745
161 ¡ 475 0.003668
162 ¢ 490 0.003784
163 £ 524 0.004046
164 ¤ 468 0.003614
165 ¥ 479 0.003699
166 ¦ 516 0.003985
167 § 502 0.003876
168 ¨ 481 0.003714
169 © 480 0.003707
170 ª 485 0.003745
171 « 523 0.004039
172 ¬ 483 0.003730
173 ­ 456 0.003521
174 ® 517 0.003992
175 ¯ 529 0.004085
176 ° 501 0.003869
177 ± 478 0.003691
178 ² 484 0.003737
179 ³ 510 0.003938
180 ´ 483 0.003730
181 µ 495 0.003822
182 ¶ 533 0.004116
183 · 499 0.003853
184 ¸ 513 0.003961
185 ¹ 523 0.004039
186 º 506 0.003907
187 » 525 0.004054
188 ¼ 518 0.004000
189 ½ 544 0.004201
190 ¾ 559 0.004317
191 ¿ 600 0.004633
192 À 503 0.003884
193 Á 498 0.003846
194 Â 486 0.003753
195 Ã 524 0.004046
196 Ä 481 0.003714
197 Å 535 0.004131
198 Æ 542 0.004185
199 Ç 554 0.004278
200 È 469 0.003622
201 É 501 0.003869
202 Ê 509 0.003931
203 Ë 486 0.003753
204 Ì 470 0.003629
205 Í 492 0.003799
206 Î 572 0.004417
207 Ï 532 0.004108
208 Ð 480 0.003707
209 Ñ 500 0.003861
210 Ò 501 0.003869
211 Ó 532 0.004108
212 Ô 471 0.003637
213 Õ 456 0.003521
214 Ö 507 0.003915
215 × 545 0.004209
216 Ø 489 0.003776
217 Ù 480 0.003707
218 Ú 491 0.003792
219 Û 551 0.004255
220 Ü 502 0.003876
221 Ý 536 0.004139
222 Þ 543 0.004193
223 ß 553 0.004270
224 à 480 0.003707
225 á 535 0.004131
226 â 528 0.004077
227 ã 554 0.004278
228 ä 496 0.003830
229 å 498 0.003846
230 æ 504 0.003892
231 ç 538 0.004154
232 è 493 0.003807
233 é 500 0.003861
234 ê 524 0.004046
235 ë 546 0.004216
236 ì 519 0.004008
237 í 510 0.003938
238 î 510 0.003938
239 ï 581 0.004487
240 ð 532 0.004108
241 ñ 583 0.004502
242 ò 532 0.004108
243 ó 536 0.004139
244 ô 509 0.003931
245 õ 506 0.003907
246 ö 517 0.003992
247 ÷ 587 0.004533
248 ø 564 0.004355
249 ù 532 0.004108
250 ú 544 0.004201
251 û 568 0.004386
252 ü 572 0.004417
253 ý 554 0.004278
254 þ 558 0.004309
255 ÿ 611 0.004718

Total: 129499 1.000000

Entropy = 7.997036 bits per byte.

Optimum compression would reduce the size
of this 129499 byte file by 0 percent.

Chi square distribution for 129499 samples is 536.80, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bytes is 129.2095 (127.5 = random).
Monte Carlo value for Pi is 3.100773757 (error 1.30 percent).
Serial correlation coefficient is 0.000181 (totally uncorrelated = 0.0).
Value Char Occurrences Fraction
0 499 0.003853
1 487 0.003761
2 514 0.003969
3 464 0.003583
4 499 0.003853
5 467 0.003606
6 489 0.003776
7 496 0.003830
8 467 0.003606
9 542 0.004185
10 470 0.003629
11 499 0.003853
12 512 0.003954
13 523 0.004039
14 502 0.003876
15 539 0.004162
16 486 0.003753
17 458 0.003537
18 476 0.003676
19 510 0.003938
20 502 0.003876
21 484 0.003737
22 453 0.003498
23 490 0.003784
24 468 0.003614
25 466 0.003598
26 502 0.003876
27 508 0.003923
28 519 0.004008
29 508 0.003923
30 523 0.004039
31 531 0.004100
32 512 0.003954
33 ! 494 0.003815
34 " 475 0.003668
35 # 511 0.003946
36 $ 461 0.003560
37 % 454 0.003506
38 & 509 0.003931
39 ' 478 0.003691
40 ( 489 0.003776
41 ) 464 0.003583
42 * 482 0.003722
43 + 504 0.003892
44 , 473 0.003653
45 - 501 0.003869
46 . 523 0.004039
47 / 498 0.003846
48 0 497 0.003838
49 1 451 0.003483
50 2 468 0.003614
51 3 536 0.004139
52 4 453 0.003498
53 5 476 0.003676
54 6 480 0.003707
55 7 541 0.004178
56 8 489 0.003776
57 9 484 0.003737
58 : 536 0.004139
59 ; 489 0.003776
60 < 515 0.003977
61 = 506 0.003907
62 > 537 0.004147
63 ? 576 0.004448
64 @ 478 0.003691
91 [ 439 0.003390
92 468 0.003614
93 ] 496 0.003830
94 ^ 497 0.003838
95 _ 521 0.004023
96 ` 515 0.003977
97 a 983 0.007591
98 b 948 0.007321
99 c 1014 0.007830
100 d 955 0.007375
101 e 998 0.007707
102 f 963 0.007436
103 g 978 0.007552
104 h 895 0.006911
105 i 967 0.007467
106 j 948 0.007321
107 k 1007 0.007776
108 l 943 0.007282
109 m 1030 0.007954
110 n 1050 0.008108
111 o 1065 0.008224
112 p 983 0.007591
113 q 961 0.007421
114 r 978 0.007552
115 s 1101 0.008502
116 t 992 0.007660
117 u 973 0.007514
118 v 1052 0.008124
119 w 1115 0.008610
120 x 999 0.007714
121 y 1017 0.007853
122 z 1077 0.008317
123 { 491 0.003792
124 | 517 0.003992
125 } 538 0.004154
126 ~ 536 0.004139
127 582 0.004494
128 500 0.003861
129 522 0.004031
130 446 0.003444
131 514 0.003969
132 486 0.003753
133 494 0.003815
134 501 0.003869
135 537 0.004147
136 493 0.003807
137 486 0.003753
138 488 0.003768
139 529 0.004085
140 447 0.003452
141 478 0.003691
142 539 0.004162
143 587 0.004533
144 442 0.003413
145 501 0.003869
146 515 0.003977
147 468 0.003614
148 472 0.003645
149 498 0.003846
150 458 0.003537
151 515 0.003977
152 503 0.003884
153 492 0.003799
154 508 0.003923
155 562 0.004340
156 517 0.003992
157 524 0.004046
158 535 0.004131
159 581 0.004487
160 485 0.003745
161 ¡ 475 0.003668
162 ¢ 490 0.003784
163 £ 524 0.004046
164 ¤ 468 0.003614
165 ¥ 479 0.003699
166 ¦ 516 0.003985
167 § 502 0.003876
168 ¨ 481 0.003714
169 © 480 0.003707
170 ª 485 0.003745
171 « 523 0.004039
172 ¬ 483 0.003730
173 ­ 456 0.003521
174 ® 517 0.003992
175 ¯ 529 0.004085
176 ° 501 0.003869
177 ± 478 0.003691
178 ² 484 0.003737
179 ³ 510 0.003938
180 ´ 483 0.003730
181 µ 495 0.003822
182 ¶ 533 0.004116
183 · 499 0.003853
184 ¸ 513 0.003961
185 ¹ 523 0.004039
186 º 506 0.003907
187 » 525 0.004054
188 ¼ 518 0.004000
189 ½ 544 0.004201
190 ¾ 559 0.004317
191 ¿ 600 0.004633
215 × 545 0.004209
223 ß 553 0.004270
224 à 983 0.007591
225 á 1033 0.007977
226 â 1014 0.007830
227 ã 1078 0.008324
228 ä 977 0.007544
229 å 1033 0.007977
230 æ 1046 0.008077
231 ç 1092 0.008432
232 è 962 0.007429
233 é 1001 0.007730
234 ê 1033 0.007977
235 ë 1032 0.007969
236 ì 989 0.007637
237 í 1002 0.007738
238 î 1082 0.008355
239 ï 1113 0.008595
240 ð 1012 0.007815
241 ñ 1083 0.008363
242 ò 1033 0.007977
243 ó 1068 0.008247
244 ô 980 0.007568
245 õ 962 0.007429
246 ö 1024 0.007907
247 ÷ 587 0.004533
248 ø 1053 0.008131
249 ù 1012 0.007815
250 ú 1035 0.007992
251 û 1119 0.008641
252 ü 1074 0.008294
253 ý 1090 0.008417
254 þ 1101 0.008502
255 ÿ 611 0.004718

Total: 129499 1.000000

Entropy = 7.556523 bits per byte.

Optimum compression would reduce the size
of this 129499 byte file by 5 percent.

Chi square distribution for 129499 samples is 58158.34, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bytes is 136.1275 (127.5 = random).
Monte Carlo value for Pi is 2.777556410 (error 11.59 percent).
Serial correlation coefficient is -0.000536 (totally uncorrelated = 0.0).
Entropy = 0.999859 bits per bit.

Optimum compression would reduce the size
of this 1035992 bit file by 0 percent.

Chi square distribution for 1035992 samples is 202.72, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bits is 0.5070 (0.5 = random).
Monte Carlo value for Pi is 3.100773757 (error 1.30 percent).
Serial correlation coefficient is 0.008076 (totally uncorrelated = 0.0).
Value Char Occurrences Fraction
0 510750 0.493006
1 525242 0.506994

Total: 1035992 1.000000

Entropy = 0.999859 bits per bit.

Optimum compression would reduce the size
of this 1035992 bit file by 0 percent.

Chi square distribution for 1035992 samples is 202.72, and randomly
would exceed this value 0.01 percent of the times.

Arithmetic mean value of data bits is 0.5070 (0.5 = random).
Monte Carlo value for Pi is 3.100773757 (error 1.30 percent).
Serial correlation coefficient is 0.008076 (totally uncorrelated = 0.0).
0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,129499,7.997036,536.796910,129.209484,3.100774,0.000181
0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,129499,7.997036,536.796910,129.209484,3.100774,0.000181
2,Value,Occurrences,Fraction
3,0,499,0.003853
3,1,487,0.003761
3,2,514,0.003969
3,3,464,0.003583
3,4,499,0.003853
3,5,467,0.003606
3,6,489,0.003776
3,7,496,0.003830
3,8,467,0.003606
3,9,542,0.004185
3,10,470,0.003629
3,11,499,0.003853
3,12,512,0.003954
3,13,523,0.004039
3,14,502,0.003876
3,15,539,0.004162
3,16,486,0.003753
3,17,458,0.003537
3,18,476,0.003676
3,19,510,0.003938
3,20,502,0.003876
3,21,484,0.003737
3,22,453,0.003498
3,23,490,0.003784
3,24,468,0.003614
3,25,466,0.003598
3,26,502,0.003876
3,27,508,0.003923
3,28,519,0.004008
3,29,508,0.003923
3,30,523,0.004039
3,31,531,0.004100
3,32,512,0.003954
3,33,494,0.003815
3,34,475,0.003668
3,35,511,0.003946
3,36,461,0.003560
3,37,454,0.003506
3,38,509,0.003931
3,39,478,0.003691
3,40,489,0.003776
3,41,464,0.003583
3,42,482,0.003722
3,43,504,0.003892
3,44,473,0.003653
3,45,501,0.003869
3,46,523,0.004039
3,47,498,0.003846
3,48,497,0.003838
3,49,451,0.003483
3,50,468,0.003614
3,51,536,0.004139
3,52,453,0.003498
3,53,476,0.003676
3,54,480,0.003707
3,55,541,0.004178
3,56,489,0.003776
3,57,484,0.003737
3,58,536,0.004139
3,59,489,0.003776
3,60,515,0.003977
3,61,506,0.003907
3,62,537,0.004147
3,63,576,0.004448
3,64,478,0.003691
3,65,468,0.003614
3,66,488,0.003768
3,67,485,0.003745
3,68,481,0.003714
3,69,520,0.004015
3,70,480,0.003707
3,71,502,0.003876
3,72,444,0.003429
3,73,493,0.003807
3,74,490,0.003784
3,75,489,0.003776
3,76,461,0.003560
3,77,488,0.003768
3,78,527,0.004070
3,79,513,0.003961
3,80,498,0.003846
3,81,486,0.003753
3,82,431,0.003328
3,83,526,0.004062
3,84,492,0.003799
3,85,475,0.003668
3,86,517,0.003992
3,87,539,0.004162
3,88,495,0.003822
3,89,499,0.003853
3,90,516,0.003985
3,91,439,0.003390
3,92,468,0.003614
3,93,496,0.003830
3,94,497,0.003838
3,95,521,0.004023
3,96,515,0.003977
3,97,515,0.003977
3,98,460,0.003552
3,99,529,0.004085
3,100,474,0.003660
3,101,478,0.003691
3,102,483,0.003730
3,103,476,0.003676
3,104,451,0.003483
3,105,474,0.003660
3,106,458,0.003537
3,107,518,0.004000
3,108,482,0.003722
3,109,542,0.004185
3,110,523,0.004039
3,111,552,0.004263
3,112,485,0.003745
3,113,475,0.003668
3,114,547,0.004224
3,115,575,0.004440
3,116,500,0.003861
3,117,498,0.003846
3,118,535,0.004131
3,119,576,0.004448
3,120,504,0.003892
3,121,518,0.004000
3,122,561,0.004332
3,123,491,0.003792
3,124,517,0.003992
3,125,538,0.004154
3,126,536,0.004139
3,127,582,0.004494
3,128,500,0.003861
3,129,522,0.004031
3,130,446,0.003444
3,131,514,0.003969
3,132,486,0.003753
3,133,494,0.003815
3,134,501,0.003869
3,135,537,0.004147
3,136,493,0.003807
3,137,486,0.003753
3,138,488,0.003768
3,139,529,0.004085
3,140,447,0.003452
3,141,478,0.003691
3,142,539,0.004162
3,143,587,0.004533
3,144,442,0.003413
3,145,501,0.003869
3,146,515,0.003977
3,147,468,0.003614
3,148,472,0.003645
3,149,498,0.003846
3,150,458,0.003537
3,151,515,0.003977
3,152,503,0.003884
3,153,492,0.003799
3,154,508,0.003923
3,155,562,0.004340
3,156,517,0.003992
3,157,524,0.004046
3,158,535,0.004131
3,159,581,0.004487
3,160,485,0.003745
3,161,475,0.003668
3,162,490,0.003784
3,163,524,0.004046
3,164,468,0.003614
3,165,479,0.003699
3,166,516,0.003985
3,167,502,0.003876
3,168,481,0.003714
3,169,480,0.003707
3,170,485,0.003745
3,171,523,0.004039
3,172,483,0.003730
3,173,456,0.003521
3,174,517,0.003992
3,175,529,0.004085
3,176,501,0.003869
3,177,478,0.003691
3,178,484,0.003737
3,179,510,0.003938
3,180,483,0.003730
3,181,495,0.003822
3,182,533,0.004116
3,183,499,0.003853
3,184,513,0.003961
3,185,523,0.004039
3,186,506,0.003907
3,187,525,0.004054
3,188,518,0.004000
3,189,544,0.004201
3,190,559,0.004317
3,191,600,0.004633
3,192,503,0.003884
3,193,498,0.003846
3,194,486,0.003753
3,195,524,0.004046
3,196,481,0.003714
3,197,535,0.004131
3,198,542,0.004185
3,199,554,0.004278
3,200,469,0.003622
3,201,501,0.003869
3,202,509,0.003931
3,203,486,0.003753
3,204,470,0.003629
3,205,492,0.003799
3,206,572,0.004417
3,207,532,0.004108
3,208,480,0.003707
3,209,500,0.003861
3,210,501,0.003869
3,211,532,0.004108
3,212,471,0.003637
3,213,456,0.003521
3,214,507,0.003915
3,215,545,0.004209
3,216,489,0.003776
3,217,480,0.003707
3,218,491,0.003792
3,219,551,0.004255
3,220,502,0.003876
3,221,536,0.004139
3,222,543,0.004193
3,223,553,0.004270
3,224,480,0.003707
3,225,535,0.004131
3,226,528,0.004077
3,227,554,0.004278
3,228,496,0.003830
3,229,498,0.003846
3,230,504,0.003892
3,231,538,0.004154
3,232,493,0.003807
3,233,500,0.003861
3,234,524,0.004046
3,235,546,0.004216
3,236,519,0.004008
3,237,510,0.003938
3,238,510,0.003938
3,239,581,0.004487
3,240,532,0.004108
3,241,583,0.004502
3,242,532,0.004108
3,243,536,0.004139
3,244,509,0.003931
3,245,506,0.003907
3,246,517,0.003992
3,247,587,0.004533
3,248,564,0.004355
3,249,532,0.004108
3,250,544,0.004201
3,251,568,0.004386
3,252,572,0.004417
3,253,554,0.004278
3,254,558,0.004309
3,255,611,0.004718
0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,129499,7.556523,58158.342590,136.127468,2.777556,-0.000536
0,File-bits,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,1035992,0.999859,202.721704,0.506994,3.100774,0.008076
0,File-bits,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
1,1035992,0.999859,202.721704,0.506994,3.100774,0.008076
2,Value,Occurrences,Fraction
3,0,510750,0.493006
3,1,525242,0.506994
*******************************
source


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class gene
{ static int tab[]={0,0,0,0,0,0,0,0};
static int index=0;
static FileOutputStream file;

public static void main(String args[])
{
if(args.length!=4)
{
System.out.println(" java gene cle_n0 cle_n1 cle_n2 qtDeNb " );
System.out.println(" cle_n0 = nb premier ");
System.out.println(" cle_n1 = nb de bit max des nb premier ");
System.out.println(" cle_n2 = puissance max de l'ecart entre deux nb
premier ");
System.out.println(" qtDeNb =nombre de tirage de 8 bit ");
System.out.println(" ex :java gene 3623 100 50 1000 ");
return;
}
BigInteger p=new BigInteger(args[0]);
if(! p.isProbablePrime(100))
{
System.out.println(p+ " n'est pas un nb premier"); return;
}
int taille=Integer.parseInt(args[1]);
int ecart=Integer.parseInt(args[2]);
int qt=Integer.parseInt(args[3]);
qt=qt*8;
try {file=new FileOutputStream ("sortie08.bin");
} catch (FileNotFoundException e){
System.out.println(e);
}
System.out.println("init ");
p=newGraine(p,taille);
System.out.println("debut ");
allea(p,ecart,qt);
}

public static void allea(BigInteger p,int val, int qt)
{
BigInteger res ,tmp_p=p;
BigInteger pow=new BigInteger("2");
BigInteger on=new BigInteger("1");
boolean stop=true,impaire=true,plus=true;
int nb=0,n=0;

while (stop)
{
p=p.add(pow);
if(p.isProbablePrime(100))
{
nb++;
res=p.subtract(tmp_p);
Mod(res.toString());
tmp_p=p;
if (n>val){n=1;}
if(nb>qt){stopúlse;}
pow=new BigInteger("2");
pow=pow.pow(n);

}
n++;
}
System.out.println();
System.out.println("************ longeure en bit **************");
System.out.println("taille "+p.toString(2).length());
}



public static BigInteger newGraine(BigInteger p,int taille )
{
BigInteger pow=new BigInteger("2");
int n =p.toString(2).length();
pow=pow.pow(n);
while (p.toString(2).length()<taille)
{
p=p.add(pow);

if(p.isProbablePrime(100))
{
System.out.print(".");
n=p.toString(2).length();
pow=new BigInteger("2");
pow=pow.pow(n);
}
}
System.out.println();
return p;
}

public static void Mod(String p)
{
int v,val=0;
for (int i=0;i<p.length();i++)
{
val=val+Character.getNumericValue(p.charAt(i));
}
v=val%2;
if(index==8){calculEntier();index=0;}
tab[index]=v;
index++;
}

public static void calculEntier()
{
int val=0,p=1;

for(int i=0;i<tab.length;i++){
val=val+tab[i]*p;
p=p*2;
}
System.out.print(val+" ");

try {file.write(val);
} catch (IOException e){
System.out.println(e);
}
}

}
Avatar
remy
re

que dans le principe cela peut le faire
mais dans la vrais vie cela ne ser pas a grand chose
un nuit complette 447 k0 de code cree
avec toujour la meme qualite
fichier compresser plus gros que la source

et que comme il ne me reste plus rien a code en crypto "algo"
depuis le temps que je vous le dit je vais bien finir par le faire
et en plus je suis devenus tros vieux pour faire quelque chose
de reellement exploitable donc
j'arrete et vous laisse tranquille

lai fote d'ortografe sont ma signature


by by remy merci a vous tous