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

问一下 #2

Open
sixgodfan opened this issue Dec 25, 2023 · 1 comment
Open

问一下 #2

sixgodfan opened this issue Dec 25, 2023 · 1 comment

Comments

@sixgodfan
Copy link

请问trx或eth的私钥跟哈希如何用正则(php)区分出来?

@wangschang
Copy link
Owner

可以使用正则表达式来区分 TRX 或 ETH 的私钥和哈希。以下是两种方法:

方法一:使用长度

TRX 私钥的长度为 64 个字符,而 ETH 私钥的长度为 66 个字符。哈希的长度通常为 64 个字符,但也可以是其他长度。因此,可以使用以下正则表达式来区分它们:

`
$regex = '/^[0-9a-f]{64}$/';

if (preg_match($regex, $string)) {
// 可能是 TRX 私钥或哈希
} else if (strlen($string) === 66) {
// 可能是 ETH 私钥
} else {
// 不是 TRX 或 ETH 私钥或哈希
}
`

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

No branches or pull requests

2 participants