1
2
3
4
5
6
7
8
9
10
11
12 package testrsa;
13
14 import java.util.Random;
15
16
17
18 public class RandomString {
19 Random rand = new Random();
20
21
22 public RandomString() {
23 }
24
25
26
27
28
29
30
31
32
33
34 public static char createChar(int temp) {
35
36 return (char)temp;
37 }
38
39
40
41
42
43
44
45
46 public static int createInt(char temp) {
47
48 return (int)temp;
49 }
50
51
52
53
54
55
56
57
58 public static void createAsciiTable(){
59 for (int z = 0; z < 256; z++){
60 char[] test3;
61 test3 = new char [1];
62 test3[0] = RandomString.createChar(z);
63 String test2 = new String(test3);
64 byte[] t3;
65 t3 = test2.getBytes();
66 int a2 = t3[0];
67 int a3 = (a2 & 0x7F) + (a2 < 0 ? 128 : 0);
68 System.out.println("mitChar: "+RandomString.createChar(z)+" "+RandomString.createInt(RandomString.createChar(z))+" mitString: "+test2+ " "+a3);
69 }
70
71 }
72
73
74
75
76
77
78
79
80 public char createRandomChar() {
81
82 int temp = this.rand.nextInt(256);
83
84
85 if(temp < 33)
86 {
87 temp = createRandomChar();
88 return (char)temp;
89 }
90
91 else {
92
93 return (char)temp;
94
95 }
96
97 }
98
99
100
101
102
103
104
105
106 public String createRandomString(int length) {
107 StringBuffer sb = new StringBuffer();
108 for (int j = 0; j < length; j++) {
109 sb.append(createRandomChar());
110 }
111 return sb.toString();
112 }
113
114
115
116 }
117