Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重构randx.RandCode以及传入的RandType数值 #240

Closed
dxyinme opened this issue Jan 9, 2024 · 3 comments · Fixed by #241
Closed

重构randx.RandCode以及传入的RandType数值 #240

dxyinme opened this issue Jan 9, 2024 · 3 comments · Fixed by #241

Comments

@dxyinme
Copy link
Contributor

dxyinme commented Jan 9, 2024

仅限中文

需要重构函数 RandCode

当前实现缺陷

无法实现随机生成 数字+大写字母 / 数字 + 小写字母 / 大写字母 + 小写字母 的这种组合

重构方案

TYPE_DIGIT   TYPE = 1 //数字
TYPE_LETTER  TYPE = 1 << 1 //小写字母
TYPE_CAPITAL TYPE = 1 << 2 //大写字母
TYPE_MIXED   TYPE = (TYPE_DIGIT | TYPE_LETTER | TYPE_CAPITAL)

然后可以通过取按位与的值来确认最终的source字符串

source := ""
if (typ & TYPE_DIGIT) == TYPE_DIGIT {
    source += DigitCharset
}
...

其它

任何你觉得有利于解决问题的补充说明

你使用的是 ekit 哪个版本?

你设置的的 Go 环境?

上传 go env 的结果

@flycash
Copy link
Contributor

flycash commented Jan 9, 2024

可以支持这个

@dxyinme
Copy link
Contributor Author

dxyinme commented Jan 9, 2024

我最近抽空写一下这个

@dxyinme
Copy link
Contributor Author

dxyinme commented Jan 12, 2024

PR: #241

@longyue0521 longyue0521 linked a pull request Jan 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants