224 lines
11 KiB
VB.net
224 lines
11 KiB
VB.net
Imports System.Data.SqlClient
|
|
Imports System.Diagnostics
|
|
Imports Microsoft.VisualBasic
|
|
Imports Konscious.Security.Cryptography
|
|
Imports System.Threading.Tasks
|
|
|
|
Public Class TestPerformance
|
|
Public Shared Sub createnUsers(ByRef n As Integer)
|
|
Dim ConnectionString = ""
|
|
|
|
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
|
|
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True
|
|
'ConnectionString = "Server=DEVELOPER\DEVSQL;Database=VERAG_HOMEPAGE;Uid=sa;Pwd=BmWr501956"
|
|
ConnectionString = "Server=DEVELOPER\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;"
|
|
Else
|
|
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False
|
|
ConnectionString = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;"
|
|
'ConnectionString = "Server=db593295684.db.1and1.com;Database=db593295684;Uid=dbo593295684;Pwd=atilla#2;"
|
|
End If
|
|
|
|
Using con As New SqlConnection(ConnectionString)
|
|
' Using cmd As New SqlCommand("Validate_User")
|
|
For nzahl As Integer = 0 To n Step 1
|
|
Dim UsrID As Integer = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(0, 15), VERAG_VARIABLES.RandomInteger(500, 4500)), VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(1500, 4500), VERAG_VARIABLES.RandomInteger(4500, 45750)))
|
|
Dim usrname As String = String.Empty
|
|
Dim pw As String = "Pw" + Convert.ToBase64String(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(0, nzahl + 2)))
|
|
Dim email As String = "ja@verag.ag"
|
|
|
|
Dim monthrndm As Integer = VERAG_VARIABLES.RandomInteger(1, 12)
|
|
Dim Yearrand As Integer = VERAG_VARIABLES.RandomInteger(2001, 2021)
|
|
Dim dayrand As Integer = VERAG_VARIABLES.RandomInteger(1, 30)
|
|
Dim datelastloggedin As Date = New Date(Yearrand, monthrndm, dayrand)
|
|
Dim monthrndm2 As Integer = VERAG_VARIABLES.RandomInteger(1, 12)
|
|
Dim Yearrand2 As Integer = VERAG_VARIABLES.RandomInteger(2001, 2021)
|
|
Dim dayrand2 As Integer = VERAG_VARIABLES.RandomInteger(1, 30)
|
|
Dim DateCreate As Date = New Date(Yearrand2, monthrndm2, dayrand2)
|
|
|
|
'Namen
|
|
Dim lstCapitals As New ArrayList
|
|
' Capital Names
|
|
lstCapitals.Add("Montgomery")
|
|
lstCapitals.Add("Juneau")
|
|
lstCapitals.Add("Phoenix")
|
|
lstCapitals.Add("Little Rock")
|
|
lstCapitals.Add("Sacramento")
|
|
lstCapitals.Add("Denver")
|
|
lstCapitals.Add("Hartford")
|
|
lstCapitals.Add("Dover")
|
|
lstCapitals.Add("Tallahassee")
|
|
lstCapitals.Add("Atlanta")
|
|
lstCapitals.Add("Honolulu")
|
|
lstCapitals.Add("Boise")
|
|
lstCapitals.Add("Springfield")
|
|
lstCapitals.Add("Indianapolis")
|
|
lstCapitals.Add("Des Moines")
|
|
lstCapitals.Add("Topeka")
|
|
lstCapitals.Add("Frankfort")
|
|
lstCapitals.Add("Baton Rouge")
|
|
lstCapitals.Add("Augusta")
|
|
lstCapitals.Add("Annapolis")
|
|
lstCapitals.Add("Boston")
|
|
lstCapitals.Add("Lansing")
|
|
lstCapitals.Add("St. Paul")
|
|
lstCapitals.Add("Jackson")
|
|
lstCapitals.Add("Jefferson City")
|
|
lstCapitals.Add("Helena")
|
|
lstCapitals.Add("Lincoln")
|
|
lstCapitals.Add("Carson City")
|
|
lstCapitals.Add("Concord")
|
|
lstCapitals.Add("Trenton")
|
|
lstCapitals.Add("Santa Fe")
|
|
lstCapitals.Add("Albany")
|
|
lstCapitals.Add("Raleigh")
|
|
lstCapitals.Add("Bismarck")
|
|
lstCapitals.Add("Columbus")
|
|
lstCapitals.Add("Oklahoma City")
|
|
lstCapitals.Add("Salem")
|
|
lstCapitals.Add("Harrisburg")
|
|
lstCapitals.Add("Providence")
|
|
lstCapitals.Add("Columbia")
|
|
lstCapitals.Add("Pierre")
|
|
lstCapitals.Add("Nashville")
|
|
lstCapitals.Add("Austin")
|
|
lstCapitals.Add("Salt Lake City")
|
|
lstCapitals.Add("Montpelier")
|
|
lstCapitals.Add("Richmond")
|
|
lstCapitals.Add("Olympia")
|
|
lstCapitals.Add("Charleston")
|
|
lstCapitals.Add("Madison")
|
|
lstCapitals.Add("Cheyenne")
|
|
|
|
'Pulls a name randomly from the list
|
|
Dim stringname As String = lstCapitals.Item(VERAG_VARIABLES.RandomInteger(0, lstCapitals.Count))
|
|
usrname = stringname
|
|
|
|
Using cmd As New SqlCommand("INSERT INTO [VERAG_HOMEPAGE].[dbo].[Users] VALUES (@UserId,@Username,@Password,@Email,@Date)")
|
|
' cmd.CommandType = CommandType.StoredProcedure
|
|
cmd.Parameters.AddWithValue("@UserId", UsrID)
|
|
cmd.Parameters.AddWithValue("@Username", usrname)
|
|
cmd.Parameters.AddWithValue("@Password", pw)
|
|
cmd.Parameters.AddWithValue("@Email", email)
|
|
cmd.Parameters.AddWithValue("@Date", DateCreate)
|
|
cmd.Parameters.AddWithValue("Dateloggedinlast", datelastloggedin)
|
|
cmd.Connection = con
|
|
con.Open()
|
|
' userId = Convert.ToInt32(cmd.ExecuteScalar())
|
|
cmd.ExecuteScalar()
|
|
con.Close()
|
|
End Using
|
|
Next
|
|
End Using
|
|
End Sub
|
|
Public Shared Sub DeleteUsers()
|
|
|
|
End Sub
|
|
Public Shared finalzeit As Long
|
|
|
|
Public Shared Function TestHashrateServer(zahlint As Integer) As String
|
|
Dim arrzahl As New List(Of Integer)
|
|
Dim arrzahl_iterats As New List(Of Integer)
|
|
Dim hashbytes As New List(Of Byte())
|
|
Dim arrzeitp1 As New List(Of Long)
|
|
Dim arrzeitp2 As New List(Of Long)
|
|
Dim arrzeitp3 As New List(Of Long)
|
|
Dim finalarr As New List(Of Byte())
|
|
Dim hashsalts As New List(Of Byte())
|
|
Dim sw1 As Stopwatch = New Stopwatch
|
|
Dim sw2 As Stopwatch = New Stopwatch
|
|
|
|
For zahl As Integer = 0 To zahlint
|
|
sw1.Start()
|
|
hashsalts.Add(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(95, Math.Pow(2, 8))))
|
|
arrzahl_iterats.Add(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 2), 68))
|
|
arrzahl.Add(zahlint)
|
|
sw1.Stop()
|
|
arrzeitp1.Add(sw1.ElapsedMilliseconds)
|
|
sw1.Reset()
|
|
Next
|
|
Dim pw As String = "PasswordV" + VERAG_VARIABLES.RandomInteger(5, zahlint - 5).ToString + "!!%"
|
|
For zahl As Integer = 0 To zahlint
|
|
sw2.Start()
|
|
hashbytes.Add(VERAG_VARIABLES.HashPassword(pw, hashsalts(zahl), arrzahl_iterats(zahl), arrzahl(zahl)))
|
|
sw2.Stop()
|
|
arrzeitp2.Add(sw2.ElapsedMilliseconds)
|
|
sw2.Reset()
|
|
Next
|
|
|
|
For Each zp1 In arrzeitp1
|
|
If arrzeitp1(zp1) < arrzeitp2(zp1) Then
|
|
arrzeitp3.Add(arrzeitp1.Item(zp1))
|
|
Else
|
|
arrzeitp3.Add(arrzeitp2.Item(zp1))
|
|
End If
|
|
Next
|
|
For Each z3 In arrzeitp3
|
|
finalarr.Add(hashbytes(z3))
|
|
Next
|
|
Dim finalhashstr As String = Convert.ToBase64String(finalarr.Min)
|
|
Dim ts As New TimeSpan(0, 0, 0, 0, arrzeitp3.Min)
|
|
'Dim finlasaltstr As String = Convert.ToBase64String(hashsalts.Min)
|
|
'Dim finalsalt As String = finlasaltstr
|
|
Dim finalitertas As String = arrzahl_iterats.Min.ToString
|
|
'Ausgabe
|
|
Return "Ergebnisse:" + Environment.NewLine + Space(1) + finalhashstr + Environment.NewLine + Space(1) + Environment.NewLine + "Zeit:" + Space(1) + ts.Hours.ToString + "Stunden:" + ts.Minutes.ToString + "Min:" + ts.Seconds.ToString + "Sekunden" + ts.Milliseconds.ToString + "Millisekunden" + Environment.NewLine + "bei " + Space(1) + finalitertas + Space(1) + "Iterationen."
|
|
End Function
|
|
Public Shared Async Function TestHashrateServerAsync(zahlint As Integer) As Task(Of String)
|
|
Dim arrzahl As New List(Of Integer)
|
|
Dim arrzahl_iterats As New List(Of Integer)
|
|
Dim hashbytes As New List(Of Byte())
|
|
Dim arrzeitp1 As New List(Of Long)
|
|
Dim arrzeitp2 As New List(Of Long)
|
|
Dim arrzeitp3 As New List(Of Long)
|
|
Dim finalarr As New List(Of Byte())
|
|
Dim hashsalts As New List(Of Byte())
|
|
Dim sw1 As Stopwatch = New Stopwatch
|
|
Dim sw2 As Stopwatch = New Stopwatch
|
|
|
|
For zahl As Integer = 0 To zahlint
|
|
sw1.Start()
|
|
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
|
|
hashsalts.Add(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(95, 104)))
|
|
Else
|
|
hashsalts.Add(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(95, 105)))
|
|
End If
|
|
arrzahl_iterats.Add(VERAG_VARIABLES.RandomInteger(25, 45))
|
|
arrzahl.Add(zahlint)
|
|
sw1.Stop()
|
|
arrzeitp1.Add(sw1.ElapsedMilliseconds)
|
|
sw1.Reset()
|
|
Next
|
|
Dim pw As String
|
|
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
|
|
pw = "PasswordV$S" + VERAG_VARIABLES.RandomInteger(115, 120 + (zahlint - 5)).ToString + "!!%"
|
|
Else
|
|
pw = "&WAS5$WdA&" + VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(120, 512), VERAG_VARIABLES.RandomInteger(300, Math.Pow(2, 13) + (zahlint - VERAG_VARIABLES.RandomInteger(5, 17))).ToString + "#*p(=+UY")
|
|
End If
|
|
For zahl As Integer = 0 To zahlint
|
|
sw2.Start()
|
|
hashbytes.Add(Await VERAG_VARIABLES.HashPasswordAsync(pw, hashsalts(zahl), arrzahl_iterats(zahl), arrzahl(zahl)))
|
|
sw2.Stop()
|
|
arrzeitp2.Add(sw2.ElapsedMilliseconds)
|
|
sw2.Reset()
|
|
Next
|
|
|
|
For Each zp1 In arrzeitp1
|
|
If arrzeitp1(zp1) < arrzeitp2(zp1) Then
|
|
arrzeitp3.Add(arrzeitp1.Item(zp1))
|
|
Else
|
|
arrzeitp3.Add(arrzeitp2.Item(zp1))
|
|
End If
|
|
Next
|
|
For Each z3 In arrzeitp3
|
|
finalarr.Add(hashbytes(z3))
|
|
Next
|
|
Dim finalhashstr As String = Convert.ToBase64String(finalarr.Min)
|
|
Dim ts As New TimeSpan(0, 0, 0, 0, arrzeitp3.Min)
|
|
'Dim finlasaltstr As String = Convert.ToBase64String(hashsalts.Min)
|
|
'Dim finalsalt As String = finlasaltstr
|
|
Dim finalitertas As String = arrzahl_iterats.Min.ToString
|
|
'Ausgabe
|
|
Return "Ergebnisse:" + Environment.NewLine + Space(1) + finalhashstr + Environment.NewLine + "Salt vom Hash:" + Space(1) + Environment.NewLine + "Zeit:" + Space(1) + ts.Hours.ToString + "Stunden:" + ts.Minutes.ToString + "Min:" + ts.Seconds.ToString + "Sekunden" + ts.Milliseconds.ToString + "Millisekunden" + Environment.NewLine + "bei " + Space(1) + finalitertas + "Iterationen."
|
|
End Function
|
|
End Class
|