吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 878|回复: 5
收起左侧

[求助] 请教ToInt64()和ToInt32()怎么转换?

[复制链接]
nirven 发表于 2022-6-24 15:56
本人小白新手,刚开始接触c#,在学习中没有经验,遇到不懂的向各位请教。

通过cmd命令“wmic CPU get ProcessorID”获得Cpucode=“BFEBFBFF00090675”程序如下:
public static string CalculateSerialNum11938836(string cpucode)
{
    string str = cpucode.Substring(cpucode.Length - 6, 3);       "从第10为开始数3个数,得到009”不知道这么理解对不对。
    string str2 = cpucode.Substring(cpucode.Length - 3, 3);     "从第13为开始数3个数,得到067”
    string str3 = (Convert.ToInt64(str, 0x10) * Convert.ToInt64(str2, 0x10)).ToString();
    string str4 = str3;
    while (str3.Length < 6)
    {
        str3 = "0" + str3;
    }
    int num2 = (Convert.ToInt32(str4) * 0xb62c14) + 0xb62c14;
    return (num2.ToString().Substring(0, 6) + str3.Substring(str3.Length - 6, 6));
}
我知道0xb62c14 是11938836
但是不知道ToInt64()和ToInt32()怎么转换,能讲解下吗

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| nirven 发表于 2022-6-24 16:34
班主能指导下吗
3yu3 发表于 2022-6-24 21:23
好象表述不够明确啊。你发的源码里Convert.ToInt64(str, 0x10)不是有实例吗?
 楼主| nirven 发表于 2022-6-24 21:57
3yu3 发表于 2022-6-24 21:23
好象表述不够明确啊。你发的源码里Convert.ToInt64(str, 0x10)不是有实例吗?

请教下num2是多少
return什么值?
3yu3 发表于 2022-6-24 22:12
本帖最后由 3yu3 于 2022-6-24 22:53 编辑

[C#] 纯文本查看 复制代码
using System;
class Program
{
    public static void Main(string[] args)
    {
        string text = CalculateSerialNum11938836("BFEBFBFF00090675");
        Console.WriteLine("最后结果= " + text);
    }
    
    public static string CalculateSerialNum11938836(string cpucode)
    {
    string str = cpucode.Substring(cpucode.Length - 6, 3);
    Console.WriteLine("str = " + str);
    
    string str2 = cpucode.Substring(cpucode.Length - 3, 3);
    Console.WriteLine("str2 = " + str2);
    
    long str_toInt64 = Convert.ToInt64(str, 0x10);
    Console.WriteLine("str_toInt64 = " + str_toInt64);
    
    long str2_toInt64 = Convert.ToInt64(str2, 0x10);
    Console.WriteLine("str2_toInt64 = " + str2_toInt64);
    
    string str3 = (str_toInt64 * str2_toInt64).ToString();
    Console.WriteLine("str3 = " + str3);
    
    string str4 = str3;
    Console.WriteLine("str4 = " + str4);
    
    while (str3.Length < 6)
    {
        str3 = "0" + str3;
    }
    Console.WriteLine("str3不足6位前面补0 = " + str3);
    
    int str4_toInt32 = Convert.ToInt32(str4);
    Console.WriteLine("str4_toInt32 = " + str4_toInt32);
    
    int num4 = str4_toInt32 * 0xb62c14;
    Console.WriteLine("str4_toInt32 * 0xb62c14 = " + num4);
    
    int num2 = (num4) + 0xb62c14;
    Console.WriteLine("num2 = " + num2);
    
    return (num2.ToString().Substring(0, 6) + str3.Substring(str3.Length - 6, 6));
    }}


https://www.bejson.com/runcode/csharp/
在线运行结果:


标准输出:
str = 090
str2 = 675


str_toInt64 = 144
str2_toInt64 = 1653


str3 = 238032
str4 = 238032


str3不足6位前面补0 = 238032


str4_toInt32 = 238032
str4_toInt32 * 0xb62c14 = -1443339200


num2 = -1431400364
最后结果= -14314238032


免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
nirven + 1 + 1 热心回复!

查看全部评分

 楼主| nirven 发表于 2022-6-25 05:28
3yu3 发表于 2022-6-24 22:12
[mw_shl_code=csharp,true]using System;
class Program
{

谢谢您,我再通过这个在线运行学习下。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-25 13:13

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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