File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .redomar .game .lib ;
2+
3+ import org .apache .commons .lang3 .StringUtils ;
4+
5+ public class HashGen {
6+
7+ private String hexHash ;
8+ private boolean prefix ;
9+ private int hexLength ;
10+
11+ public HashGen (boolean showPrefix , int length ){
12+ this .prefix = showPrefix ;
13+ this .hexLength = length ;
14+ init ();
15+ }
16+
17+ private void init (){
18+ if (prefix ){
19+ hexHash = "0x" ;
20+ } else {
21+ hexHash = "" ;
22+ }
23+ }
24+
25+ public String getHash (){
26+ setHash (hexLength );
27+ return hexHash ;
28+ }
29+
30+ private void setHash (int hexLength ){
31+
32+ String hex ;
33+
34+ for (int i = 0 ; i < hexLength ; i ++){
35+ hex = Integer .toHexString (randNumGen ());
36+ hex = StringUtils .capitalize (hex );
37+ hexHash = hexHash + hex ;
38+ }
39+
40+ }
41+
42+ private int randNumGen (){
43+ int rand = (int )(Math .random () * 16 );
44+ return rand ;
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments