none
VB.net Base64问题 RRS feed

  • 问题

  •  Public Function EncodeBase64(ByVal code As String) As String
            Dim encode As String = ""
            Dim bytes As Byte() = Encoding.Default.GetBytes(code)
            Try
                encode = Convert.ToBase64String(bytes)
            Catch
                encode = code
            End Try
            Return encode
        End Function
    
    
        Public Function DecodeBase64(ByVal code As String) As String
            Dim decode As String = ""
            Dim bytes As Byte() = Convert.FromBase64String(code)
            Try
                decode = Encoding.Default.GetString(bytes)
            Catch
                decode = code
            End Try
            Return decode
        End Function
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
                Dim xtms, xtxx, xtlx ,jsjm, yhm, cpu,cpuid, zbcs, zbid,ypcs, ypid, ip,mac, ncrl, xkcs ,xk, scsj As String
                xtms = EncodeBase64(Label14.Text)
                xtxx = EncodeBase64(TextBox1.Text)
                xtlx = EncodeBase64(TextBox2.Text)
                jsjm = EncodeBase64(TextBox3.Text)
                yhm = EncodeBase64(TextBox4.Text)
                cpu = EncodeBase64(TextBox5.Text)
                cpuid = EncodeBase64(TextBox6.Text)
                zbcs = EncodeBase64(TextBox7.Text)
                zbid = EncodeBase64(TextBox8.Text)
                ypcs = EncodeBase64(TextBox9.Text)
                ypid = EncodeBase64(TextBox10.Text)
                ip = EncodeBase64(TextBox11.Text)
                mac = EncodeBase64(TextBox12.Text)
                ncrl = EncodeBase64(TextBox13.Text)
                xkcs = EncodeBase64(TextBox14.Text)
                xk = EncodeBase64(TextBox15.Text)
                scsj = EncodeBase64(ToolStripStatusLabel2.Text)
    
                My.Computer.FileSystem.WriteAllText("data.ini", "[信息配置]" + vbCrLf + "系统模式:" + xtms + vbCrLf + "系统信息:" + xtxx + vbCrLf + "系统类型:" + xtlx + vbCrLf + "计算机名:" + jsjm + vbCrLf + "用户名:" + yhm + vbCrLf + "CPU:" + cpu + vbCrLf + "CPUID:" + cpuid + vbCrLf + "主板厂商:" + zbcs + vbCrLf + "主板序号:" + zbid + vbCrLf + "硬盘厂商:" + ypcs + vbCrLf + "硬盘序号:" + ypid + vbCrLf + "IP地址:" + ip + vbCrLf + "MAC地址:" + mac + vbCrLf + "内存容量:" + "MB" + ncrl + vbCrLf + "显卡厂商:" + xkcs + vbCrLf + "显卡:" + xk + vbCrLf + "生成时间:" + scsj, False)
    
                MsgBox("已记录")
    
    

    上面的代码是加密并存入文件的代码,打开文件并进行解密和保存文件要怎么写呢?
    直接读取已存的文件吗,解密我该如何写, 具体用哪些命令参数及语句呢?



    • 已编辑 dt7575 2018年7月9日 1:46
    2018年7月9日 0:30

答案

  • Hi dt7575

    https://www.cnblogs.com/guohu/p/5562759.html

    是否试着使用上面三种常用的加密方式,RSA与DES都是可加密可解密的。

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • 已标记为答案 dt7575 2018年7月9日 14:32
    2018年7月9日 3:26

全部回复

  • Hi dt7575

    https://www.cnblogs.com/guohu/p/5562759.html

    是否试着使用上面三种常用的加密方式,RSA与DES都是可加密可解密的。

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • 已标记为答案 dt7575 2018年7月9日 14:32
    2018年7月9日 3:26
  • 谢谢。

    2018年7月9日 3:59
  • Hi 

    问题解决了吗?如果解决了,帮忙将解决方案标记为答案,谢谢。

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年7月9日 5:15