29-03-18, 02:53 PM
الكود التالي مجرد فكرة تم كتابتها بأسلوب مختلف قليلا
و سهل تطويرها لتعطي نتائج افضل
و سهل تطويرها لتعطي نتائج افضل
PHP كود :
Public Class Form1
Private Delegate Sub SerialCallBack(Of T)(ByRef value As T)
Private Sub EncruptInfo(info As Byte(), callback As SerialCallBack(Of Integer), ByRef result As Integer())
Dim bool As Integer = If(info IsNot Nothing, 1, 0)
If bool > 0 Then
result = New Integer(info.Length - 1) {}
Dim i As Integer = 0
While i < info.Length
Dim ptr As IntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(i)
Dim value As Integer = CInt(info(i))
callback(value)
System.Runtime.InteropServices.Marshal.WriteInt32(ptr, value)
result(i) = System.Runtime.InteropServices.Marshal.ReadInt32(ptr)
System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr)
i += 1
End While
End If
End Sub
Private Function GetSerials(info As Byte()) As Integer()
Dim result As Integer() = Nothing
EncruptInfo(info, New SerialCallBack(Of Integer)(AddressOf Me.ApplySerialCallBack), result)
Return result
End Function
Private Sub ApplySerialCallBack(ByRef value As Integer)
Dim size As Integer = System.Runtime.InteropServices.Marshal.SizeOf(GetType(Int32))
size *= size
value = value * size
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' حدد اسم العميل
Dim info As String = "Any Name"
' تحويل اسم العميل الي مصفوفة بايت
Dim bytes As Byte() = New Byte(info.Length - 1) {}
Dim k As Integer = 0
While k < info.Length
bytes(k) = AscW(info(k).ToString)
k += 1
End While
Dim serials As Integer() = GetSerials(bytes)
Dim serial As String = ""
Dim i As Integer = 0
While i < serials.Length
serial += serials(i).ToString + " "
i += 1
End While
' الحصول علي سيريال العيل
serial = serial.TrimEnd(" ")
End Sub
End Class
Retired

