精易论坛
标题:
随机字符串生成问题
[打印本页]
作者:
叶凡ui
时间:
2024-12-12 14:17
标题:
随机字符串生成问题
我在jadx里面找到他一个UUID的生成方法调用的命令是:
String
replaceAll
=
UUID
.
randomUUID
(
)
.
toString
(
)
.
replaceAll
(
"-"
,
""
)
;
我想问下易语言能做到Java代码中的这种生成他指定的随机字符串吗,最后的结果是返回一个32位的字符串:
e868538c5cab0dbe8f817d7f55482ef4(随机的)
jadx代码贴在下面
package
java
.
util
;
import
java.io.Serializable
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
okhttp3.internal.ws.WebSocketProtocol
;
/* loaded from: classes.dex */
public
final
class
UUID
implements
Serializable
,
Comparable
<
UUID
>
{
static
final
/* synthetic */
boolean
$assertionsDisabled
=
false
;
private
static
final
long
serialVersionUID
=
-
4856846361193249489L
;
private
final
long
leastSigBits
;
private
final
long
mostSigBits
;
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes.dex */
public
static
class
Holder
{
static
final
SecureRandom
numberGenerator
=
new
SecureRandom
(
)
;
private
Holder
(
)
{
}
}
private
UUID
(
byte
[
data
)
{
long
msb
=
0
;
long
lsb
=
0
;
for
(
int
i2
=
0
;
i2
<
8
;
i2
++
)
{
msb
=
(
msb
<
<
8
)
|
(
data
[
i2
&
255
)
;
}
for
(
int
i3
=
8
;
i3
<
16
;
i3
++
)
{
lsb
=
(
lsb
<
<
8
)
|
(
data
[
i3
&
255
)
;
}
this
.
mostSigBits
=
msb
;
this
.
leastSigBits
=
lsb
;
}
public
UUID
(
long
mostSigBits
,
long
leastSigBits
)
{
this
.
mostSigBits
=
mostSigBits
;
this
.
leastSigBits
=
leastSigBits
;
}
public
static
UUID
randomUUID
(
)
{
SecureRandom
ng
=
Holder
.
numberGenerator
;
byte
[
randomBytes
=
new
byte
[
16
;
ng
.
nextBytes
(
randomBytes
)
;
randomBytes
[
6
=
(
byte
)
(
randomBytes
[
6
&
15
)
;
randomBytes
[
6
=
(
byte
)
(
randomBytes
[
6
|
64
)
;
randomBytes
[
8
=
(
byte
)
(
randomBytes
[
8
&
63
)
;
randomBytes
[
8
=
(
byte
)
(
randomBytes
[
8
|
128
)
;
return
new
UUID
(
randomBytes
)
;
}
public
static
UUID
nameUUIDFromBytes
(
byte
[
name
)
{
try
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
)
;
byte
[
md5Bytes
=
md
.
digest
(
name
)
;
md5Bytes
[
6
=
(
byte
)
(
md5Bytes
[
6
&
15
)
;
md5Bytes
[
6
=
(
byte
)
(
md5Bytes
[
6
|
48
)
;
md5Bytes
[
8
=
(
byte
)
(
md5Bytes
[
8
&
63
)
;
md5Bytes
[
8
=
(
byte
)
(
md5Bytes
[
8
|
128
)
;
return
new
UUID
(
md5Bytes
)
;
}
catch
(
NoSuchAlgorithmException
nsae
)
{
throw
new
InternalError
(
"MD5 not supported"
,
nsae
)
;
}
}
public
static
UUID
fromString
(
String
name
)
{
String
[
components
=
name
.
split
(
"-"
)
;
if
(
components
.
length
!=
5
)
{
throw
new
IllegalArgumentException
(
"Invalid UUID string: "
+
name
)
;
}
for
(
int
i2
=
0
;
i2
<
5
;
i2
++
)
{
components
[
i2
=
"0x"
+
components
[
i2
;
}
long
mostSigBits
=
Long
.
decode
(
components
[
0
)
.
longValue
(
)
;
long
mostSigBits2
=
(
(
(
mostSigBits
<
<
16
)
|
Long
.
decode
(
components
[
1
)
.
longValue
(
)
)
<
<
16
)
|
Long
.
decode
(
components
[
2
)
.
longValue
(
)
;
long
leastSigBits
=
Long
.
decode
(
components
[
3
)
.
longValue
(
)
;
return
new
UUID
(
mostSigBits2
,
(
leastSigBits
<
<
48
)
|
Long
.
decode
(
components
[
4
)
.
longValue
(
)
)
;
}
public
long
getLeastSignificantBits
(
)
{
return
this
.
leastSigBits
;
}
public
long
getMostSignificantBits
(
)
{
return
this
.
mostSigBits
;
}
public
int
version
(
)
{
return
(
int
)
(
(
this
.
mostSigBits
>>
12
)
&
15
)
;
}
public
int
variant
(
)
{
long
j2
=
this
.
leastSigBits
;
return
(
int
)
(
(
j2
>>
63
)
&
(
j2
>>>
(
(
int
)
(
64
-
(
j2
>>>
62
)
)
)
)
)
;
}
public
long
timestamp
(
)
{
if
(
version
(
)
!=
1
)
{
throw
new
UnsupportedOperationException
(
"Not a time-based UUID"
)
;
}
long
j2
=
this
.
mostSigBits
;
return
(
j2
>>>
32
)
|
(
(
4095
&
j2
)
<
<
48
)
|
(
(
(
j2
>>
16
)
&
WebSocketProtocol
.
PAYLOAD_SHORT_MAX
)
<
<
32
)
;
}
public
int
clockSequence
(
)
{
if
(
version
(
)
!=
1
)
{
throw
new
UnsupportedOperationException
(
"Not a time-based UUID"
)
;
}
return
(
int
)
(
(
this
.
leastSigBits
&
4611404543450677248L
)
>>>
48
)
;
}
public
long
node
(
)
{
if
(
version
(
)
!=
1
)
{
throw
new
UnsupportedOperationException
(
"Not a time-based UUID"
)
;
}
return
this
.
leastSigBits
&
281474976710655L
;
}
public
String
toString
(
)
{
return
digits
(
this
.
mostSigBits
>>
32
,
8
)
+
"-"
+
digits
(
this
.
mostSigBits
>>
16
,
4
)
+
"-"
+
digits
(
this
.
mostSigBits
,
4
)
+
"-"
+
digits
(
this
.
leastSigBits
>>
48
,
4
)
+
"-"
+
digits
(
this
.
leastSigBits
,
12
)
;
}
private
static
String
digits
(
long
val
,
int
digits
)
{
long
hi
=
1
<
<
(
digits
*
4
)
;
return
Long
.
toHexString
(
(
(
hi
-
1
)
&
val
)
|
hi
)
.
substring
(
1
)
;
}
public
int
hashCode
(
)
{
long
hilo
=
this
.
mostSigBits
^
this
.
leastSigBits
;
return
(
(
int
)
(
hilo
>>
32
)
)
^
(
(
int
)
hilo
)
;
}
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
null
|
|
obj
.
getClass
(
)
!=
UUID
.
class
)
{
return
false
;
}
UUID
id
=
(
UUID
)
obj
;
return
this
.
mostSigBits
==
id
.
mostSigBits
&&
this
.
leastSigBits
==
id
.
leastSigBits
;
}
@Override
// java.lang.Comparable
public
int
compareTo
(
UUID
val
)
{
long
j2
=
this
.
mostSigBits
;
long
j3
=
val
.
mostSigBits
;
if
(
j2
<
j3
)
{
return
-
1
;
}
if
(
j2
>
j3
)
{
return
1
;
}
long
j4
=
this
.
leastSigBits
;
long
j5
=
val
.
leastSigBits
;
if
(
j4
<
j5
)
{
return
-
1
;
}
return
j4
>
j5
?
1
:
0
;
}
}
作者:
LEOONL
时间:
2024-12-12 14:17
精易模块 调试输出 (文本_取随机字符 (32, 3))
补充内容 (2024-12-12 14:21):
或者 调试输出 (到小写 (子文本替换 (程序_生成GUID (), “-”, , , , 真)))
欢迎光临 精易论坛 (https://125.confly.eu.org/)
Powered by Discuz! X3.4