【问题标题】:Convert VB.NET code to PHP将 VB.NET 代码转换为 PHP
【发布时间】:2014-10-13 04:00:08
【问题描述】:

我在 VB.Net 中有 MD5 字符串的代码,但我想将其转换为具有相同值返回的 php
VB.Net 代码:

Public Shared Function ConverFileName(ByVal FileName As String) As String
        Dim str2 As String = ""
        Dim provider As New MD5CryptoServiceProvider
        Try 
            Dim buffer As Byte() = provider.ComputeHash(Encoding.Default.GetBytes(FileName))
            Dim num2 As Integer = (buffer.Length - 1)
            Dim i As Integer = 0
            Do While (i <= num2)
                str2 = (str2 & StringType.FromByte(buffer(i)))
                i += 1
            Loop
        Catch exception1 As Exception
            ProjectData.SetProjectError(exception1)
            Dim exception As Exception = exception1
            ProjectData.ClearProjectError
        End Try
        Return str2
    End Function

【问题讨论】:

    标签: php vb.net md5


    【解决方案1】:

    PHP 中已经内置了计算文件 MD5 Hash 的函数。

    md5_file($filename)

    示例#1 md5_file() 的使用示例

    <?php
    $file = 'php-5.3.0alpha2-Win32-VC9-x64.zip';
    
    echo 'MD5 file hash of ' . $file . ': ' . md5_file($file);
    ?>
    

    或者如果你需要找到一个字符串的 MD5 Has,那么

    http://php.net/manual/en/function.md5.php

    <?php
    $str = 'apple';
    
    echo 'MD5 hash of ' . $str. ': ' . md5($str);
    ?>
    

    【讨论】:

      【解决方案2】:

      你能帮忙从vb net改成php到

      Function Enkrip(pwd As String) As String
          Dim s As String
          s = ""
          For i = 1 To Len(pwd)
              s = s + Chr(Asc(Mid(pwd, i, 1)) + 32)
          Next i
          Enkrip = s
      End Function
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-09-16
        • 2010-11-06
        • 1970-01-01
        • 1970-01-01
        • 2013-08-01
        • 1970-01-01
        • 2010-09-21
        相关资源
        最近更新 更多