Audiovox P965 Datenblatt Seite 160

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 280
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 159
API in VB dot NET
157
Send("/login")
Send("=name=" + user)
Send("=response=00" + EncodePassword(pass, hash), True)
Dim res = Read()
If (res(0) = "!done") Then Return True Else Return False
End Function
Function EncodePassword(ByVal pass As String, ByVal challange As String) As String
Dim hash_byte(challange.Length / 2 - 1) As Byte
For i = 0 To challange.Length - 2 Step 2
hash_byte(i / 2) = Byte.Parse(challange.Substring(i, 2), Globalization.NumberStyles.HexNumber)
Next
Dim response(pass.Length + hash_byte.Length) As Byte
response(0) = 0
Text.Encoding.ASCII.GetBytes(pass.ToCharArray()).CopyTo(response, 1)
hash_byte.CopyTo(response, 1 + pass.Length)
Dim md5 = New System.Security.Cryptography.MD5CryptoServiceProvider()
Dim hash = md5.ComputeHash(response)
Dim hashStr As New Text.StringBuilder()
For Each h In hash
hashStr.Append(h.ToString("x2"))
Next
Return hashStr.ToString()
End Function
Public Sub Send(ByVal command As String, Optional ByVal EndSentence As Boolean = False)
Dim bytes = System.Text.Encoding.ASCII.GetBytes(command.ToCharArray())
Dim size = EncodeLength(bytes.Length)
tcpStream.Write(size, 0, size.Length)
tcpStream.Write(bytes, 0, bytes.Length)
If EndSentence Then tcpStream.WriteByte(0)
End Sub
Public Function Read() As List(Of String)
Dim output As New List(Of String)
Dim o = ""
Dim tmp(4) As Byte
Dim count As Long
While True
tmp(3) = tcpStream.ReadByte()
Select Case tmp(3)
Seitenansicht 159
1 2 ... 155 156 157 158 159 160 161 162 163 164 165 ... 279 280

Kommentare zu diesen Handbüchern

Keine Kommentare