开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 252|回复: 1
收起左侧

[完成] 随机字符串生成问题

 关闭 [复制链接]
结帖率:100% (17/17)
发表于 2024-12-12 14:17:22 | 显示全部楼层 |阅读模式   云南省德宏傣族景颇族自治州
100精币
我在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;
    }
}

最佳答案

查看完整内容

精易模块 调试输出 (文本_取随机字符 (32, 3)) 补充内容 (2024-12-12 14:21): 或者 调试输出 (到小写 (子文本替换 (程序_生成GUID (), “-”, , , , 真)))

签到天数: 22 天

发表于 2024-12-12 14:17:23 | 显示全部楼层   四川省宜宾市
精易模块 调试输出 (文本_取随机字符 (32, 3))

补充内容 (2024-12-12 14:21):
或者 调试输出 (到小写 (子文本替换 (程序_生成GUID (), “-”, , , , 真)))

评分

参与人数 2精币 +2 荣誉 +1 收起 理由
笨潴 + 1 热心帮助他人,荣誉+1,希望继续努力(*^__^*) 嘻嘻!
真IKUN + 2 新技能已get√

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表