Anpassungen Variablen/Logik

This commit is contained in:
ja
2021-12-31 09:28:29 +01:00
parent 31d62f79d9
commit 284a7c26a1
10 changed files with 392 additions and 161 deletions

View File

@@ -2,7 +2,7 @@
Imports System.Diagnostics Imports System.Diagnostics
Imports Microsoft.VisualBasic Imports Microsoft.VisualBasic
Imports Konscious.Security.Cryptography Imports Konscious.Security.Cryptography
Imports System.Threading.Tasks
Public Class TestPerformance Public Class TestPerformance
Public Shared Sub createnUsers(ByRef n As Integer) Public Shared Sub createnUsers(ByRef n As Integer)
@@ -108,7 +108,6 @@ Public Class TestPerformance
con.Close() con.Close()
End Using End Using
Next Next
End Using End Using
End Sub End Sub
Public Shared Sub DeleteUsers() Public Shared Sub DeleteUsers()
@@ -116,7 +115,7 @@ Public Class TestPerformance
End Sub End Sub
Public Shared finalzeit As Long Public Shared finalzeit As Long
Public Shared Function TestHashrateServer(zahlint As Integer) As Byte() Public Shared Function TestHashrateServer(zahlint As Integer) As String
Dim arrzahl As New List(Of Integer) Dim arrzahl As New List(Of Integer)
Dim arrzahl_iterats As New List(Of Integer) Dim arrzahl_iterats As New List(Of Integer)
Dim hashbytes As New List(Of Byte()) Dim hashbytes As New List(Of Byte())
@@ -127,11 +126,10 @@ Public Class TestPerformance
Dim hashsalts As New List(Of Byte()) Dim hashsalts As New List(Of Byte())
Dim sw1 As Stopwatch = New Stopwatch Dim sw1 As Stopwatch = New Stopwatch
Dim sw2 As Stopwatch = New Stopwatch Dim sw2 As Stopwatch = New Stopwatch
Dim finalhash As Byte()
For zahl As Integer = 0 To zahlint For zahl As Integer = 0 To zahlint
sw1.Start() sw1.Start()
hashsalts.Add(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 7)))) hashsalts.Add(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 8))))
arrzahl_iterats.Add(VERAG_VARIABLES.getiterationnumber) arrzahl_iterats.Add(VERAG_VARIABLES.getiterationnumber)
arrzahl.Add(zahlint) arrzahl.Add(zahlint)
sw1.Stop() sw1.Stop()
@@ -157,9 +155,60 @@ Public Class TestPerformance
For Each z3 In arrzeitp3 For Each z3 In arrzeitp3
finalarr.Add(hashbytes(z3)) finalarr.Add(hashbytes(z3))
Next Next
finalhash = finalarr.Min Dim finalhashstr As String = Convert.ToBase64String(finalarr.Min)
finalzeit = arrzeitp3.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 'Ausgabe
Return finalhash 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()
hashsalts.Add(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 8))))
arrzahl_iterats.Add(VERAG_VARIABLES.getiterationnumber)
arrzahl.Add(zahlint)
sw1.Stop()
arrzeitp1.Add(sw1.ElapsedMilliseconds)
sw1.Reset()
Next
Dim pw As String = "q!V64nS4"
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 Function
End Class End Class

View File

@@ -1,6 +1,8 @@
Imports System.Security.Cryptography Imports System.Security.Cryptography
Imports Microsoft.VisualBasic Imports Microsoft.VisualBasic
Imports Konscious.Security.Cryptography Imports Konscious.Security.Cryptography
Imports System.Threading.Tasks
Public Class VERAG_VARIABLES Public Class VERAG_VARIABLES
Public Shared errornumb As Integer = 0 Public Shared errornumb As Integer = 0
Shared Function getiterationnumber() As Integer Shared Function getiterationnumber() As Integer
@@ -27,6 +29,7 @@ Public Class VERAG_VARIABLES
Return saltBytes Return saltBytes
'Convert.ToBase64String(saltBytes) 'Convert.ToBase64String(saltBytes)
End Function End Function
Public Shared Function HashPassword(password As String, salt As Byte(), nIterations As Integer, nHash As Integer) As Byte() Public Shared Function HashPassword(password As String, salt As Byte(), nIterations As Integer, nHash As Integer) As Byte()
'Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(password)) 'Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(password))
@@ -41,18 +44,43 @@ Public Class VERAG_VARIABLES
Else Else
Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password))) Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password)))
Argon.Salt = salt Argon.Salt = salt
Argon.DegreeOfParallelism = 50 Argon.DegreeOfParallelism = 24 * (nHash / nHash * 1.03)
Argon.Iterations = nIterations * VERAG_VARIABLES.RandomInteger(1, 3) Argon.Iterations = nIterations * VERAG_VARIABLES.RandomInteger(1, 3)
Argon.MemorySize = (((nIterations * 8.485 - (nIterations * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 416) Argon.MemorySize = (((nIterations * 8.485 - (nIterations * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 416)
Return Argon.GetBytes(nHash) Return Argon.GetBytes(nHash)
End If End If
End Function
Public Shared Async Function HashPasswordAsync(password As String, salt As Byte(), nIterations As Integer, nHash As Integer) As Task(Of Byte())
'Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(password))
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password)))
Argon.Salt = salt
Argon.DegreeOfParallelism = 24
Argon.Iterations = nIterations * 2
Argon.MemorySize = (((nIterations * 4.98 - (nIterations * 1.23) / 4 * 1.5) / 1.05) + 1 * 290)
Return Await Argon.GetBytesAsync(nHash)
Else
Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password)))
Argon.Salt = salt
Argon.DegreeOfParallelism = 24 * (nHash / nHash * 1.03)
Argon.Iterations = nIterations * VERAG_VARIABLES.RandomInteger(1, 3)
Argon.MemorySize = (((nIterations * 8.485 - (nIterations * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 416)
Return Await Argon.GetBytesAsync(nHash)
End If
End Function End Function
Public Shared Function Verifyhash(ByVal passw As String, salt As Byte(), ByVal hash As Byte(), ByVal nIterations As Integer, ByVal nHash As Integer) As Boolean Public Shared Function Verifyhash(ByVal passw As String, salt As Byte(), ByVal hash As Byte(), ByVal nIterations As Integer, ByVal nHash As Integer) As Boolean
Dim newHash As Byte() = HashPassword(passw, salt, nIterations, nHash) Dim newHash As Byte() = HashPassword(passw, salt, nIterations, nHash)
Return hash.SequenceEqual(newHash) Return hash.SequenceEqual(newHash)
End Function End Function
Public Shared Async Function VerifyhashAsync(ByVal passw As String, salt As Byte(), ByVal hash As Byte(), ByVal nIterations As Integer, ByVal nHash As Integer) As Task(Of Boolean)
Dim newHash As Byte() = Await HashPasswordAsync(passw, salt, nIterations, nHash)
Return hash.SequenceEqual(newHash)
End Function
Public Shared Function RandomInteger(ByVal min As Integer, ByVal max As Integer) As Integer Public Shared Function RandomInteger(ByVal min As Integer, ByVal max As Integer) As Integer
Dim rand As New RNGCryptoServiceProvider() Dim rand As New RNGCryptoServiceProvider()
Dim one_byte() As Byte = {0} Dim one_byte() As Byte = {0}

View File

@@ -623,8 +623,7 @@
<script type="text/javascript" src="../js/scrollscript.js"></script> <script type="text/javascript" src="../js/scrollscript.js"></script>
<!-- JQUERY Script fuer Modal--> <!-- JQUERY Script fuer Modal-->
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!-- jQuery CDN - Slim version (=without AJAX) -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<!-- Popper.JS --> <!-- Popper.JS -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<!-- Bootstrap JS --> <!-- Bootstrap JS -->

View File

@@ -80,26 +80,14 @@
<tr><td> <tr><td>
<tr><td><asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /></td></tr> <tr><td><asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /></td></tr>
<tr><td><input type="range" ID="sld_getbenchmarkheat" runat="server" AutoPostback="True" data-bs-toggle="tooltip" data-bs-placement="top" title="Disabled! Still under construction!" disabled="false" aria-disabled="false"/></td><td><asp:Label ID="lbl_valslider" runat="server">Wert der Stufe(1-100)</asp:Label></td></tr> <tr><td><input type="range" ID="sld_getbenchmarkheat" runat="server" AutoPostback="True" data-bs-toggle="tooltip" data-bs-placement="top" title="Disabled! Still under construction!" disabled="false" aria-disabled="false"/></td><td><asp:Label ID="lbl_valslider" runat="server">Wert der Stufe(1-100)</asp:Label></td></tr>
<tr><td><asp:Button ID="btn_TesthashrateServer" data-bs-toggle="tooltip" data-bs-placement="top" title="Disabled! Still under construction!" Enabled="true" runat="server" Font-Overline="false" BorderStyle="Dashed" ClientIDMode="AutoID" OnClick="btn_TesthashrateServer_ClickAsync" Text="Test hashrate of Server!" /></td></tr> <tr><td><asp:Button ID="btn_TesthashrateServer" data-bs-toggle="tooltip" data-bs-placement="top" title="Disabled! Still under construction!" Enabled="true" runat="server" Font-Overline="false" BorderStyle="Dashed" ClientIDMode="AutoID" OnClick="btn_TesthashrateServer_ClickAsync" Text="" /></td></tr>
<tr><td><asp:Label runat="server" ID="lbl_Status" Text="Hier wird das Ergebnis des Benchmark Tests angezeigt!"></asp:Label></td></tr></table> <tr><td><asp:Label runat="server" ID="lbl_Status" Text="Hier wird das Ergebnis des Benchmark Tests angezeigt!" style="color:darkcyan"></asp:Label></td></tr></table>
</ContentTemplate> </ContentTemplate>
</asp:UpdatePanel> </asp:UpdatePanel>
<script> <script>
var slider = document.getElementById('<%=sld_getbenchmarkheat.ClientID%>'); var slider = document.getElementById('<%=sld_getbenchmarkheat.ClientID%>');
$('<%=lbl_valslider.ClientID%>').change(function () { slider.value = parseInt(this.value) }); $('<%=lbl_valslider.ClientID%>').change(function () { slider.value = parseInt(this.value) });
</script> </script>
<script>
$(document).ready(function () {
$('<%=btn_TesthashrateServer.ClientID%>').on('click', function (e) {
if ((e.target.id === 'ok') || (e.target.id === 'cancel')) {
return ();
} else {
// display message box
alert("Wirklich?")
}
})
});
</script>
</asp:Content> </asp:Content>

View File

@@ -9,32 +9,41 @@ Partial Class Customers_Default2
If Page.IsPostBack Then If Page.IsPostBack Then
Page.MaintainScrollPositionOnPostBack = True Page.MaintainScrollPositionOnPostBack = True
If Not HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
btn_TesthashrateServer.Text = "Test hashrate of the Server!"
Else
btn_TesthashrateServer.Text = "Test hashrate of the local machine!"
End If
VERAG_VARIABLES.initerrorcount() VERAG_VARIABLES.initerrorcount()
If Integer.Parse(sld_getbenchmarkheat.Value) < 10 Then If Integer.Parse(sld_getbenchmarkheat.Value) < 10 Then
MemorySizelocal = (((nIterations * 1) * 4.68 - ((nIterations * 2) * 1.23) / 4 * 1.5) / 1.05) + 0.75 * 254 MemorySizelocal = (((nIterations * 1) * 4.28 - ((nIterations * 2) * 1.23) / 4 * 1.5) / 1.05) + 0.75 * 354
MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2)) * 7.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2)) * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 400 MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2)) * 5.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2)) * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 400
randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 0), Math.Pow(2, 1)), Math.Pow(2, 2)) randzahl = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 2), Math.Pow(2, 4))
ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 10 And Integer.Parse(sld_getbenchmarkheat.Value) < 40 Then ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 10 And Integer.Parse(sld_getbenchmarkheat.Value) < 40 Then
MemorySizelocal = (((nIterations * 2) * 4.68 - ((nIterations * 2) * 1.23) / 4 * 1.5) / 1.05) + 0.75 * 290 MemorySizelocal = (((nIterations * 1.255) * 4.48 - ((nIterations * 1.12) * 1.23) / 4 * 1.5) / 1.05) + 0.75 * 390
MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2)) * 7.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2)) * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 416 MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.5)) * 6.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2)) * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 516
randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 0), Math.Pow(2, 2)), Math.Pow(2, 4)) randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 0), Math.Pow(2, 2)), Math.Pow(2, 4))
ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 40 And Integer.Parse(sld_getbenchmarkheat.Value) < 60 Then ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 40 And Integer.Parse(sld_getbenchmarkheat.Value) < 60 Then
MemorySizelocal = (((nIterations * 2.45) * 4.98 - ((nIterations * 1.15) * 1.23) / 4 * 1.5) / 1.05) + 0.95 * 290 MemorySizelocal = (((nIterations * 1.45) * 4.98 - ((nIterations * 1.15) * 1.23) / 4 * 1.5) / 1.05) + 0.95 * 420
MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 7.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 0.56) / 1.85 * 2.28) / 7.28) + 1.024 * 416 MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 7.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 0.56) / 1.85 * 2.28) / 7.28) + 1.024 * 646
randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 0), Math.Pow(2, 4)), VERAG_VARIABLES.RandomInteger(Math.Pow(2, 3), Math.Pow(2, 4))) randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 0), Math.Pow(2, 4)), VERAG_VARIABLES.RandomInteger(Math.Pow(2, 3), Math.Pow(2, 4)))
ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 60 And Integer.Parse(sld_getbenchmarkheat.Value) < 80 Then ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 60 And Integer.Parse(sld_getbenchmarkheat.Value) < 80 Then
MemorySizelocal = (((nIterations * 2.45) * 4.98 - ((nIterations * 2) * 1.23) / 4 * 1.5) / 1.05) + 1 * 290 MemorySizelocal = (((nIterations * 1.85) * 4.98 - ((nIterations * 2) * 1.23) / 4 * 1.5) / 1.05) + 1 * 790
MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 8.585 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 0.56) / 1.85 * 2.28) / 7.28) + 1.024 * 416 MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 8.585 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 2.32)) * 0.56) / 1.85 * 2.28) / 7.28) + 1.024 * 816
randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 5)), VERAG_VARIABLES.RandomInteger(Math.Pow(2, 5), Math.Pow(2, 7))) randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 5)), VERAG_VARIABLES.RandomInteger(Math.Pow(2, 5), Math.Pow(2, 7)))
ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 80 And Integer.Parse(sld_getbenchmarkheat.Value) < 100 Then ElseIf Integer.Parse(sld_getbenchmarkheat.Value) > 80 And Integer.Parse(sld_getbenchmarkheat.Value) < 100 Then
MemorySizelocal = (((nIterations * 2) * 4.98 - ((nIterations * 2) * 1.23) / 4 * 1.5) / 1.05) + 1 * 290 MemorySizelocal = (((nIterations * 2) * 4.98 - ((nIterations * 2) * 1.23) / 4 * 1.5) / 1.05) + 1 * 290
MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 3)) * 9.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 3)) * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 416 MemorySizeProductionServ = (((nIterations * VERAG_VARIABLES.RandomInteger(1, 3)) * 9.485 - ((nIterations * VERAG_VARIABLES.RandomInteger(1, 3)) * 0.56) / 1.85 * 2.28) / 8.28) + 1.024 * 416
randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 5), Math.Pow(2, 6)), VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 7))) randzahl = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(Math.Pow(2, 3), Math.Pow(2, 4)), VERAG_VARIABLES.RandomInteger(Math.Pow(2, 5), Math.Pow(2, 7)))
End If End If
Else Else
Page.MaintainScrollPositionOnPostBack = False Page.MaintainScrollPositionOnPostBack = False
VERAG_VARIABLES.initerrorcount() VERAG_VARIABLES.initerrorcount()
If Not HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
btn_TesthashrateServer.Text = "Test hashrate of the Server!"
Else
btn_TesthashrateServer.Text = "Test hashrate of the local machine!"
End If
End If End If
End Sub End Sub
@@ -61,25 +70,25 @@ Partial Class Customers_Default2
End If End If
End Sub End Sub
Protected Sub btn_TesthashrateServer_ClickAsync(sender As Object, e As EventArgs) Handles btn_TesthashrateServer.Click Protected Async Sub btn_TesthashrateServer_ClickAsync(sender As Object, e As EventArgs) Handles btn_TesthashrateServer.Click
Dim Boole As Boolean = New Boolean Dim Boole As Boolean = New Boolean
Dim ram As Double = Double.Parse(My.Computer.Info.TotalPhysicalMemory.ToString) Dim ram As Double = Double.Parse(My.Computer.Info.TotalPhysicalMemory.ToString)
Dim pwhashresult As Byte() Dim pwhashresult As String
If MemorySizelocal < ram And HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then If MemorySizelocal <= ram - (10 * 1024) And HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
pwhashresult = TestPerformance.TestHashrateServer(randzahl) pwhashresult = Await TestPerformance.TestHashrateServerAsync(randzahl)
Boole = True Boole = True
ElseIf MemorySizeProductionServ < ram And Not HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then ElseIf MemorySizeProductionServ <= ram - 2048 And Not HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
pwhashresult = TestPerformance.TestHashrateServer(randzahl) pwhashresult = Await TestPerformance.TestHashrateServerAsync(randzahl)
Boole = True Boole = True
Else Else
Boole = False Boole = False
End If End If
If Boole = True AndAlso HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then If Boole = True AndAlso HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
lbl_Status.ForeColor = Drawing.Color.Green lbl_Status.ForeColor = Drawing.Color.Green
lbl_Status.Text = "Der Test wurde erfolgreich bestanden! Der Salt lautet:" + Convert.ToBase64String(pwhashresult) + System.Environment.NewLine + "der Ram betrug:" + MemorySizelocal.ToString lbl_Status.Text = "Der Test wurde erfolgreich bestanden!" + System.Environment.NewLine + "Der Hash lautet:" + pwhashresult + System.Environment.NewLine + "der Ram betrug:" + MemorySizelocal.ToString
ElseIf Boole = True AndAlso Not HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then ElseIf Boole = True AndAlso Not HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
lbl_Status.ForeColor = Drawing.Color.Green lbl_Status.ForeColor = Drawing.Color.Green
lbl_Status.Text = "Der Test wurde erfolgreich bestanden! Der Hash lautet:" + Convert.ToBase64String(pwhashresult) + System.Environment.NewLine + "der Ram betrug:" + MemorySizeProductionServ.ToString lbl_Status.Text = "Der Test wurde erfolgreich bestanden!" + System.Environment.NewLine + "Der Hash lautet:" + pwhashresult + System.Environment.NewLine + "der Ram betrug:" + MemorySizeProductionServ.ToString
ElseIf Boole = False AndAlso HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then ElseIf Boole = False AndAlso HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
lbl_Status.ForeColor = Drawing.Color.Red lbl_Status.ForeColor = Drawing.Color.Red
lbl_Status.Text = "Test fehlgeschlagen! Es fehlen mindestens " + MemorySizelocal - ram + "Bytes RAM!" lbl_Status.Text = "Test fehlgeschlagen! Es fehlen mindestens " + MemorySizelocal - ram + "Bytes RAM!"

View File

@@ -108,7 +108,7 @@
<asp:Button ID="btn_Suchen_M" OnClick="btn_Suchen_M_Click" runat="server" CssClass="btn btn-primary" Text="Suchen" style="margin-left:0px" /></div> <asp:Button ID="btn_Suchen_M" OnClick="btn_Suchen_M_Click" runat="server" CssClass="btn btn-primary" Text="Suchen" style="margin-left:0px" /></div>
</div> </div>
<div style="height:12px"></div> <div style="height:12px"></div>
<div style="height:17px"></div> <div style="height:17px"></div>
<div class="col-12-flex"> <div class="col-12-flex">
<asp:Table ID="tbl_2" runat="server"> <asp:Table ID="tbl_2" runat="server">
@@ -133,17 +133,22 @@
<asp:Table ID="tbl_mainpage_M" runat="server" Width="100%" CssClass="table table-striped col-12"> <asp:Table ID="tbl_mainpage_M" runat="server" Width="100%" CssClass="table table-striped col-12">
<asp:TableHeaderRow runat="server" ID="headrow_M" style="background-color:#043381;color:#fff"><asp:TableHeaderCell ID="tblhc_SDLNr_M">SDL_Nr</asp:TableHeaderCell><asp:TableHeaderCell ID="tblhc_Bez_M">Bezeichnung</asp:TableHeaderCell><asp:TableHeaderCell ID="tbl_gueltig_M">Gültig Bis</asp:TableHeaderCell><asp:TableHeaderCell ID="tblhc_KarteNr_M">Karten-Nummer</asp:TableHeaderCell></asp:TableHeaderRow> <asp:TableHeaderRow runat="server" ID="headrow_M" style="background-color:#043381;color:#fff"><asp:TableHeaderCell ID="tblhc_SDLNr_M">SDL_Nr</asp:TableHeaderCell><asp:TableHeaderCell ID="tblhc_Bez_M">Bezeichnung</asp:TableHeaderCell><asp:TableHeaderCell ID="tbl_gueltig_M">Gültig Bis</asp:TableHeaderCell><asp:TableHeaderCell ID="tblhc_KarteNr_M">Karten-Nummer</asp:TableHeaderCell></asp:TableHeaderRow>
</asp:Table> </asp:Table>
</div>
</div> </div>
</div> </div>
</ContentTemplate></asp:UpdatePanel> </ContentTemplate></asp:UpdatePanel>
<!-- jQuery CDN - Slim version (=without AJAX) --> <!-- jQuery CDN - Slim version (=without AJAX)
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>-->
<!-- Popper.JS --> <!-- jQuery CDN - min version -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.1.1.min.js">
<!-- Popper.JS -->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>-->
<!-- Production version -->
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script> <script>
</script> </script>
<script type="text/javascript"> <script>
function TableRow_Click(Nat, Kennzeichen,tempstrarr) { function TableRow_Click(Nat, Kennzeichen,tempstrarr) {
@@ -175,7 +180,7 @@
alert(error); alert(error);
} }
function TableRow_Click_M(Nat, Kennzeichen,tempstrarr_M) { function TableRow_Click_M(Nat, Kennzeichen,tempstrarr_M) {
debugger //debugger
let Speditionslabel = document.getElementById("<%=lbl_sped_Placeholder_M.ClientID%>"); let Speditionslabel = document.getElementById("<%=lbl_sped_Placeholder_M.ClientID%>");
let natplaceholder = document.getElementById("<%=lbl_Placeholder_M.ClientID%>"); let natplaceholder = document.getElementById("<%=lbl_Placeholder_M.ClientID%>");
let table_M = document.getElementById("<%=tbl_mainpage_M.ClientID%>") let table_M = document.getElementById("<%=tbl_mainpage_M.ClientID%>")
@@ -310,36 +315,51 @@
} }
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
function doPostBack(id) { function doPostBack(id) {
let Speditionslabel = document.getElementById("<%=lbl_sped_Placeholder.ClientID%>") let Speditionslabel = document.getElementById('<%=lbl_sped_Placeholder.ClientID%>');
let natplaceholder = document.getElementById("<%=lbl_Placeholder.ClientID%>") let natplaceholder = document.getElementById('<%=lbl_Placeholder.ClientID%>');
Speditionslabel.textContent = id.split(',')[0]; alert(id)
natplaceholder.textContent = id.split(',')[1]; let table = document.getElementById('<%=tbl_mainpage.ClientID%>');
const obj = JSON.parse(id.split(',')[2]); var rowCount = table.rows.length;
for (let i = 0; i <= obj.length; i++) {
let SDL = obj[i].result;
let Bez = obj[i++].result;
let Datguenstig = obj[i++].result;
let KartNr = obj[i++].result;
Pagemethods.filltable2(<%=tbl_mainpage%>, SDL, Bez, Datguenstig, KartNr) for (let i = rowCount - 1; i > 0; i--) {
table.deleteRow(i);
} }
Speditionslabel.textContent = id.split(',')[0];
natplaceholder.textContent = id.split(',')[1];
addheader()
debugger
//for (let i = 0; i <= 5; i++) {
// let SDL = "453543535434334543";
// let Bez = "Diesel";
// let Datguenstig = "01/05/2021";
//let KartNr = "6005222022021";
//addNewRow(SDL,Bez,Datguenstig,KartNr)
// Pagemethods.filltable2(<%' =tbl_mainpage %> , SDL, Bez, Datguenstig, KartNr)
//}
Pagemethods.filltable2(id.split(',')[0])
} }
function doPostBack_M(id) { function doPostBack_M(id) {
let Speditionslabel = document.getElementById("<%=lbl_sped_Placeholder.ClientID%>") let Speditionslabel = document.getElementById("<%=lbl_sped_Placeholder_M.ClientID%>")
let natplaceholder = document.getElementById("<%=lbl_Placeholder.ClientID%>") let natplaceholder = document.getElementById("<%=lbl_Placeholder_M.ClientID%>")
Speditionslabel.textContent = id.split(',')[0]; Speditionslabel.textContent = id.split(',')[0];
natplaceholder.textContent = id.split(',')[1]; natplaceholder.textContent = id.split(',')[1];
const obj = JSON.parse(id.split(",")[2]) let table_M = document.getElementById("<%=tbl_mainpage_M.ClientID%>")
alert(obj.result) var rowCount = table_M.rows.length;
for (let i = rowCount - 1; i > 0; i--) {
table_M.deleteRow(i);
}
addheader_M()
for (let i = 0; i <= obj.length; i++) { for (let i = 0; i <= obj.length; i++) {
let SDL = obj[i].result; let SDL = obj[i].result;
let Bez = obj[i++].result; let Bez = obj[i++].result;
let Datguenstig = obj[i++].result; let Datguenstig = obj[i++].result;
let KartNr = obj[i++].result; let KartNr = obj[i++].result;
Pagemethods.filltable2_M(<%=tbl_mainpage_M%>, SDL, Bez, Datguenstig, KartNr) Pagemethods.filltable2_M(id.split(',')[0])
} }
} }
</script> </script>

View File

@@ -2,6 +2,7 @@
Imports System Imports System
Imports System.ComponentModel Imports System.ComponentModel
Imports System.Web.Script.Serialization Imports System.Web.Script.Serialization
Imports System.Web.Script.Services
Imports System.Web.Security Imports System.Web.Security
Imports System.Web.Services Imports System.Web.Services
Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls
@@ -132,10 +133,10 @@ Partial Class LKWS
For Each l2 In list2 For Each l2 In list2
Dim String2 As String = String.Empty Dim String2 As String = String.Empty
If IsNothing(l2.Schadstoffklasse) = False Then If IsNothing(l2.Kategorie) = True Then
Stringtemp = l2.Kategorie.ToString Stringtemp = "Keine Angabe"
Else Else
Stringtemp = String.Empty Stringtemp = l2.Kategorie.ToString
End If End If
Dim tc_SDL As TableCell = New TableCell Dim tc_SDL As TableCell = New TableCell
@@ -166,7 +167,7 @@ Partial Class LKWS
strtemp2 = l1.Nationalität strtemp2 = l1.Nationalität
End If End If
tr1.Attributes.Add("onclick", "Javascript:doPostBack('""" + tr1.Cells.Item(0).Text + """,""" + strtemp2 + """,""" + ConvertToJSON(list3) + """')") tr1.Attributes.Add("onclick", "Javascript:doPostBack('""" + tr1.Cells.Item(0).Text + """,""" + strtemp2 + """')")
cnt += 1 cnt += 1
tbl_sidemenue.Rows.Add(tr1) tbl_sidemenue.Rows.Add(tr1)
Next Next
@@ -265,8 +266,8 @@ Partial Class LKWS
initcells(tblhrow, tbhc_KFZKennz, tbhc_Nat, tblhc_Verk, tblhc_Kz, tblhc_Verm, tr2, tc_KfzKennz, tc_Nationalitaet, tc_Verk, tc_KZ_An, tc_Vermerk, cnt) initcells(tblhrow, tbhc_KFZKennz, tbhc_Nat, tblhc_Verk, tblhc_Kz, tblhc_Verm, tr2, tc_KfzKennz, tc_Nationalitaet, tc_Verk, tc_KZ_An, tc_Vermerk, cnt)
tr2.Attributes.Add("onclick", "Javascript:doPostBack('""" + tr2.Cells.Item(0).Text + """,""" + strtempnat + """,""" + ConvertToJSON(list3) + """')") tr2.Attributes.Add("onclick", "Javascript:doPostBack('""" + tr2.Cells.Item(0).Text + """,""" + strtempnat + """,""" + ConvertToJSON(list3) + """')")
tbl_sidemenue.Rows.Add(tr2) tbl_sidemenue.Rows.Add(tr2)
cnt += 1 cnt += 1
Next Next
End Sub End Sub
Protected Sub btn_Suchen_M_Click(sender As Object, e As EventArgs) Protected Sub btn_Suchen_M_Click(sender As Object, e As EventArgs)
@@ -397,7 +398,7 @@ Partial Class LKWS
For Each l2 In list2 For Each l2 In list2
Dim String2 As String = String.Empty Dim String2 As String = String.Empty
If IsNothing(l2.Schadstoffklasse) = False Then If IsNothing(l2.Kategorie) = False Then
Stringtemp_M = l2.Kategorie.ToString Stringtemp_M = l2.Kategorie.ToString
Else Else
Stringtemp_M = String.Empty Stringtemp_M = String.Empty
@@ -435,37 +436,51 @@ Partial Class LKWS
End Sub End Sub
<WebMethod> <WebMethod>
Public Sub filltable2(Tbl As Table, SDLNr As String, Bezeichnung As String, GueltigBis As String, KartNr As String) <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
Dim tc_SDLNr As TableCell = New TableCell Public Sub filltable2(Kennzeichen As String)
Dim tc_Bezeichnung As TableCell = New TableCell Dim tbl As Table = New Table
Dim tc_GueltigBis As TableCell = New TableCell Dim list2 As List(Of VERAG_PROG_ALLGEMEIN.cSDL) = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB_LKW(401940, Kennzeichen)
Dim tc_KartNr As TableCell = New TableCell For Each l2 In list2
Dim tr As TableRow = New TableRow Dim tc_SDLNr As TableCell = New TableCell
tc_SDLNr.Text = SDLNr Dim tc_Bezeichnung As TableCell = New TableCell
tc_Bezeichnung.Text = Bezeichnung Dim tc_GueltigBis As TableCell = New TableCell
tc_GueltigBis.Text = GueltigBis Dim tc_KartNr As TableCell = New TableCell
tc_KartNr.Text = KartNr Dim tr As TableRow = New TableRow
tr.Cells.Add(tc_SDLNr)
tr.Cells.Add(tc_Bezeichnung) tc_SDLNr.Text = l2.SDLNr.ToString
tr.Cells.Add(tc_GueltigBis) tc_Bezeichnung.Text = l2.Kategorie.ToString
tr.Cells.Add(tc_KartNr) tc_GueltigBis.Text = l2.GültigBis.ToString
Tbl.Rows.Add(tr) tc_KartNr.Text = l2.KartenNr.ToString
tr.Cells.Add(tc_SDLNr)
tr.Cells.Add(tc_Bezeichnung)
tr.Cells.Add(tc_GueltigBis)
tr.Cells.Add(tc_KartNr)
tr.Attributes.Add("style", "background-color:#ff2500;color:#fff;font-weight:400;")
tbl.Rows.Add(tr)
Next
End Sub End Sub
<WebMethod> <WebMethod>
Public Sub filltable_M(Tbl As Table, SDLNr As String, Bezeichnung As String, GueltigBis As String, KartNr As String) <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
Dim tc_SDLNr As TableCell = New TableCell Public Sub filltable_M(Kennzeichen As String)
Dim tc_Bezeichnung As TableCell = New TableCell Dim list2 As List(Of VERAG_PROG_ALLGEMEIN.cSDL) = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB_LKW(401940, Kennzeichen)
Dim tc_GueltigBis As TableCell = New TableCell Dim Tbl As New Table
Dim tc_KartNr As TableCell = New TableCell For Each l2 In list2
Dim tr_M As TableRow = New TableRow Dim tc_SDLNr As TableCell = New TableCell
tc_SDLNr.Text = SDLNr Dim tc_Bezeichnung As TableCell = New TableCell
tc_Bezeichnung.Text = Bezeichnung Dim tc_GueltigBis As TableCell = New TableCell
tc_GueltigBis.Text = GueltigBis Dim tc_KartNr As TableCell = New TableCell
tc_KartNr.Text = KartNr Dim tr_M As TableRow = New TableRow
tr_M.Cells.Add(tc_SDLNr)
tr_M.Cells.Add(tc_Bezeichnung) tc_SDLNr.Text = l2.SDLNr.ToString
tr_M.Cells.Add(tc_GueltigBis) tc_Bezeichnung.Text = l2.Kategorie.ToString
tr_M.Cells.Add(tc_KartNr) tc_GueltigBis.Text = l2.GültigBis.ToString
Tbl.Rows.Add(tr_M) tc_KartNr.Text = l2.KartenNr.ToString
tr_M.Cells.Add(tc_SDLNr)
tr_M.Cells.Add(tc_Bezeichnung)
tr_M.Cells.Add(tc_GueltigBis)
tr_M.Cells.Add(tc_KartNr)
tr_M.Attributes.Add("style", "background-color:#ff2500;color:#fff;font-weight:400;")
Tbl.Rows.Add(tr_M)
Next
End Sub End Sub
End Class End Class

View File

@@ -129,7 +129,7 @@ Partial Class login_Change_PW
MsgBox("") MsgBox("")
End Sub End Sub
Protected Sub btn_submitpw_Click(sender As Object, e As EventArgs) Protected Async Sub btn_submitpw_Click(sender As Object, e As EventArgs)
Dim tempstr As String = "" Dim tempstr As String = ""
Dim UsernameDB As String = String.Empty Dim UsernameDB As String = String.Empty
Dim pwDB As String = String.Empty Dim pwDB As String = String.Empty
@@ -240,8 +240,8 @@ Partial Class login_Change_PW
ConnectionString = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;" 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;" 'ConnectionString = "Server=db593295684.db.1and1.com;Database=db593295684;Uid=dbo593295684;Pwd=atilla#2;"
End If End If
Dim isPasswhash As Byte() = gensaltPassw(usrname, tempstr, intzahliterats, intzahl, Email, Session.IsNewSession) Dim isPasswhash As Byte() = Await gensaltPassw(usrname, tempstr, intzahliterats, intzahl, Email, Session.IsNewSession)
Dim isPasswDBhash As Byte() = gensaltPassw(UsernameDB, pwDB, intzahliterats, intzahl, EmailDB, Session.IsNewSession) Dim isPasswDBhash As Byte() = Await gensaltPassw(UsernameDB, pwDB, intzahliterats, intzahl, EmailDB, Session.IsNewSession)
If regexval_txt_Pw.IsValid = True Then If regexval_txt_Pw.IsValid = True Then
If VERAG_VARIABLES.Verifyhash(txt_Pw.Text, salt, isPasswDBhash, intzahliterats, intzahl) = True And VERAG_VARIABLES.Verifyhash(txt_Pw_WH.Text, salt, VERAG_VARIABLES.HashPassword(txt_Pw.Text, salt, intzahliterats, intzahl), intzahliterats, intzahl) = True Then If VERAG_VARIABLES.Verifyhash(txt_Pw.Text, salt, isPasswDBhash, intzahliterats, intzahl) = True And VERAG_VARIABLES.Verifyhash(txt_Pw_WH.Text, salt, VERAG_VARIABLES.HashPassword(txt_Pw.Text, salt, intzahliterats, intzahl), intzahliterats, intzahl) = True Then
Using con As New SqlConnection(ConnectionString) Using con As New SqlConnection(ConnectionString)
@@ -356,7 +356,7 @@ Partial Class login_Change_PW
End If End If
End Sub End Sub
Protected Sub btn_submitpw_M_Click(sender As Object, e As EventArgs) Protected Async Sub btn_submitpw_M_Click(sender As Object, e As EventArgs)
Dim tempstr As String = "" Dim tempstr As String = ""
Dim pwDB As String = String.Empty Dim pwDB As String = String.Empty
Dim EmailDB As String = String.Empty Dim EmailDB As String = String.Empty
@@ -459,8 +459,8 @@ Partial Class login_Change_PW
End If End If
Using con As New SqlConnection(ConnectionString) Using con As New SqlConnection(ConnectionString)
Dim isPasswhash As Byte() = gensaltPassw(usrname, tempstr, intzahliterats, intzahl, Email, Session.IsNewSession) Dim isPasswhash As Byte() = Await gensaltPassw(usrname, tempstr, intzahliterats, intzahl, Email, Session.IsNewSession)
Dim isPasswDBhash As Byte() = gensaltPassw(usrnmDB, pwDB, intzahliterats, intzahl, EmailDB, Session.IsNewSession) Dim isPasswDBhash As Byte() = Await gensaltPassw(usrnmDB, pwDB, intzahliterats, intzahl, EmailDB, Session.IsNewSession)
If regexval_txt_Pw.IsValid = True Then If regexval_txt_Pw.IsValid = True Then
If VERAG_VARIABLES.Verifyhash(tempstr, salt, isPasswhash, intzahliterats, intzahl) = True AndAlso VERAG_VARIABLES.Verifyhash(pwDB, salt, isPasswDBhash, intzahliterats, intzahl) = True Then If VERAG_VARIABLES.Verifyhash(tempstr, salt, isPasswhash, intzahliterats, intzahl) = True AndAlso VERAG_VARIABLES.Verifyhash(pwDB, salt, isPasswDBhash, intzahliterats, intzahl) = True Then
Using cmd As New SqlCommand("UPDATE [VERAG_HOMEPAGE].[dbo].[Users] SET Password=@Password WHERE Username=@Username AND UserId=@UserId") Using cmd As New SqlCommand("UPDATE [VERAG_HOMEPAGE].[dbo].[Users] SET Password=@Password WHERE Username=@Username AND UserId=@UserId")
@@ -528,12 +528,12 @@ Partial Class login_Change_PW
End If End If
End Sub End Sub
Function gensaltPassw(username As String, password As String, intzahliterats As Integer, intzahl As Integer, email As String, isnewSession As Boolean) As Byte() Async Function gensaltPassw(username As String, password As String, intzahliterats As Integer, intzahl As Integer, email As String, isnewSession As Boolean) As Task(Of Byte())
If isnewSession = False Then If isnewSession = False Then
Dim token As Byte() Dim token As Byte()
'Dim tok As Byte = Convert.ToBase64String(time.Concat(Key).ToArray()) 'Dim tok As Byte = Convert.ToBase64String(time.Concat(Key).ToArray())
Dim tok As String = password Dim tok As String = password
token = VERAG_VARIABLES.HashPassword(password, salt, intzahliterats, intzahl) token = Await VERAG_VARIABLES.HashPasswordAsync(password, salt, intzahliterats, intzahl)
Return token Return token
End If End If
End Function End Function

View File

@@ -29,7 +29,7 @@ Partial Class ForgotPW
End Sub End Sub
Protected Sub btn_Send_Click(sender As Object, e As EventArgs) Protected Async Sub btn_Send_Click(sender As Object, e As EventArgs)
Try Try
Dim username As String = String.Empty Dim username As String = String.Empty
Dim password As String = String.Empty Dim password As String = String.Empty
@@ -210,7 +210,7 @@ Partial Class ForgotPW
End Using End Using
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID) tokenname = Await genToken(username, password, email, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Session.Add("SessID", VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(Session.SessionID)) Session.Add("SessID", VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(Session.SessionID))
Else Else
@@ -219,7 +219,7 @@ Partial Class ForgotPW
Dim intzahl As Integer = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 10)) Dim intzahl As Integer = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 10))
Dim hashdata As Byte() = VERAG_VARIABLES.HashPassword(tokenname, VERAG_VARIABLES.GenerateSalt(intzahl), VERAG_VARIABLES.getiterationnumber, intzahl) Dim hashdata As Byte() = VERAG_VARIABLES.HashPassword(tokenname, VERAG_VARIABLES.GenerateSalt(intzahl), VERAG_VARIABLES.getiterationnumber, intzahl)
Session.Add("TokenHashtokenized", VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(Convert.ToBase64String(hashdata))) Session.Add("TokenHashtokenized", VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(Convert.ToBase64String(hashdata)))
If SendEmail(username, password, email, tokenname, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID) = True Then If Await SendEmail(username, password, email, tokenname, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID) = True Then
'password = RandomString(New Random, 10) 'password = RandomString(New Random, 10)
If (getDateoftoken(tokenname) = True) Then If (getDateoftoken(tokenname) = True) Then
'Dim msgboxstyle = vbDefaultButton1 + vbOK 'Dim msgboxstyle = vbDefaultButton1 + vbOK
@@ -235,7 +235,7 @@ Partial Class ForgotPW
'MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!") 'MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!")
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID) tokenname = Await genToken(username, password, email, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Else Else
tokenname = Session.Item("TokenforEmail") tokenname = Session.Item("TokenforEmail")
@@ -245,7 +245,7 @@ Partial Class ForgotPW
'MsgBox("Mail would be sent successfully!") 'MsgBox("Mail would be sent successfully!")
lblMessage.ForeColor = Color.Green lblMessage.ForeColor = Color.Green
lblMessage.Text = "The Password-Reset-Link has been mailed to the valid Address given." lblMessage.Text = "The Password-Reset-Link has been mailed to the valid Address given."
ElseIf SendEmail(username, password, email, tokenname, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID) = True Then ElseIf Await SendEmail(username, password, email, tokenname, customerID, isusrnmright, isCustomeridright, isemailright, Session.IsNewSession, UserID) = True Then
'MsgBox("Mail would not be sent successfully!") 'MsgBox("Mail would not be sent successfully!")
lblMessage.ForeColor = Color.Red lblMessage.ForeColor = Color.Red
If String.IsNullOrWhiteSpace(username) = True Then If String.IsNullOrWhiteSpace(username) = True Then
@@ -275,7 +275,7 @@ Partial Class ForgotPW
End Try End Try
End Sub End Sub
Protected Sub btn_Send_M_Click(sender As Object, e As EventArgs) Protected Async Sub btn_Send_M_Click(sender As Object, e As EventArgs)
Dim username As String = String.Empty Dim username As String = String.Empty
Dim password As String = String.Empty Dim password As String = String.Empty
@@ -454,7 +454,7 @@ Partial Class ForgotPW
End Using End Using
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID) tokenname = Await genToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Session.Add("SessID", VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(Session.SessionID)) Session.Add("SessID", VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(Session.SessionID))
Else Else
@@ -467,7 +467,7 @@ Partial Class ForgotPW
'md5temptoken = gensaltToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID) 'md5temptoken = gensaltToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID)
'MsgBox("Token:" + tokenname + Environment.NewLine + "md5" + md5temptoken) 'MsgBox("Token:" + tokenname + Environment.NewLine + "md5" + md5temptoken)
If SendEmail_M(username, password, email, tokenname, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID) = True Then If Await SendEmail_M(username, password, email, tokenname, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID) = True Then
'password = RandomString(New Random, 10) 'password = RandomString(New Random, 10)
If (getDateoftoken(tokenname) = True) Then If (getDateoftoken(tokenname) = True) Then
'Dim msgboxstyle = vbDefaultButton1 + vbOK 'Dim msgboxstyle = vbDefaultButton1 + vbOK
@@ -482,7 +482,7 @@ Partial Class ForgotPW
'MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!") 'MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!")
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID) tokenname = Await genToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Else Else
tokenname = Session.Item("TokenforEmail") tokenname = Session.Item("TokenforEmail")
@@ -492,7 +492,7 @@ Partial Class ForgotPW
'MsgBox("Mail would be sent successfully!") 'MsgBox("Mail would be sent successfully!")
lblMessage_M.ForeColor = Color.Green lblMessage_M.ForeColor = Color.Green
lblMessage_M.Text = "The Password-Reset-Link has been mailed to the valid E-Mail Address given." lblMessage_M.Text = "The Password-Reset-Link has been mailed to the valid E-Mail Address given."
ElseIf SendEmail_M(username, password, email, tokenname, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID) = True Then ElseIf Await SendEmail_M(username, password, email, tokenname, customerID, isusernameright, isuserIDright, isuserEmailright, Session.IsNewSession, UserID) = True Then
'MsgBox("Mail would not be sent successfully!") 'MsgBox("Mail would not be sent successfully!")
lblMessage_M.ForeColor = Color.Red lblMessage_M.ForeColor = Color.Red
If String.IsNullOrWhiteSpace(username) = True Then If String.IsNullOrWhiteSpace(username) = True Then
@@ -516,7 +516,7 @@ Partial Class ForgotPW
End If End If
End Sub End Sub
Function SendEmail_M(username As String, password As String, email As String, tokenname As String, customerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, sessionisnew As Boolean, theUserID As String) As Boolean Async Function SendEmail_M(username As String, password As String, email As String, tokenname As String, customerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, sessionisnew As Boolean, theUserID As String) As Task(Of Boolean)
Dim getdomianenvironment As String = String.Empty Dim getdomianenvironment As String = String.Empty
Dim pagename As String = String.Empty Dim pagename As String = String.Empty
Dim ServPort As String = String.Empty Dim ServPort As String = String.Empty
@@ -562,13 +562,13 @@ Partial Class ForgotPW
Try Try
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID) tokenname = Await genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Else Else
tokenname = Session.Item("TokenforEmail").ToString() tokenname = Session.Item("TokenforEmail").ToString()
End If End If
'Dim Strtemp = Session.Keys.Item("urltochangepw") 'Dim Strtemp = Session.Keys.Item("urltochangepw")
If getDateoftoken(tokenname) = True Then If Await getDateoftokenAsync(tokenname) = True Then
' Dim attachment As Attachment = New Attachment(File.OpenRead(excel), "Kundenliste.xlsx") ' Dim attachment As Attachment = New Attachment(File.OpenRead(excel), "Kundenliste.xlsx")
' Msg.Attachments.Add(attachment) ' Msg.Attachments.Add(attachment)
If String.IsNullOrEmpty(mailto) = False AndAlso String.IsNullOrEmpty(Betreff) = False AndAlso String.IsNullOrEmpty(htmlbody) = False Then If String.IsNullOrEmpty(mailto) = False AndAlso String.IsNullOrEmpty(Betreff) = False AndAlso String.IsNullOrEmpty(htmlbody) = False Then
@@ -589,7 +589,7 @@ Partial Class ForgotPW
lblMessage_M.Text = VERAG_VARIABLES.geterrornumb + "Mail not delivered!" lblMessage_M.Text = VERAG_VARIABLES.geterrornumb + "Mail not delivered!"
'MsgBox("Error02: Mail not delivered!" & vbCrLf & "New Token has been generated.") 'MsgBox("Error02: Mail not delivered!" & vbCrLf & "New Token has been generated.")
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID) tokenname = Await genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Session.Add("USerID", customerID) Session.Add("USerID", customerID)
Else Else
@@ -611,11 +611,11 @@ Partial Class ForgotPW
Async Function Findtokenhashsalt(username As String, password As String, email As String, customerID As String, isusernameright As Boolean, isuserIDright As Boolean, isuserEmailright As Boolean, isnewsess As Boolean, UserID As String) As Task(Of String) Async Function Findtokenhashsalt(username As String, password As String, email As String, customerID As String, isusernameright As Boolean, isuserIDright As Boolean, isuserEmailright As Boolean, isnewsess As Boolean, UserID As String) As Task(Of String)
Dim t As Task(Of String) Dim t As Task(Of String)
t = Task.Run(Async Function() As Task(Of String) t = Task.Run(Async Function() As Task(Of String)
Return gensaltToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, isnewsess, UserID, VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 7))) Return Await gensaltToken(username, password, email, customerID, isusernameright, isuserIDright, isuserEmailright, isnewsess, UserID, VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 7)))
End Function) End Function)
Return Await t Return Await t
End Function End Function
Function SendEmail(username As String, password As String, email As String, tokenname As String, customerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, sessionisnew As Boolean, theUserID As String) As Boolean Async Function SendEmail(username As String, password As String, email As String, tokenname As String, customerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, sessionisnew As Boolean, theUserID As String) As Task(Of Boolean)
Dim getdomianenvironment As String = String.Empty Dim getdomianenvironment As String = String.Empty
Dim pagename As String = String.Empty Dim pagename As String = String.Empty
Dim ServPort As String = String.Empty Dim ServPort As String = String.Empty
@@ -661,14 +661,14 @@ Partial Class ForgotPW
Try Try
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID) tokenname = Await genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Else Else
tokenname = Session.Item("TokenforEmail").ToString() tokenname = Session.Item("TokenforEmail").ToString()
End If End If
'Dim Strtemp = Session.Keys.Item("urltochangepw") 'Dim Strtemp = Session.Keys.Item("urltochangepw")
If getDateoftoken(tokenname) = True Then If Await getDateoftokenAsync(tokenname) = True Then
' Dim attachment As Attachment = New Attachment(File.OpenRead(excel), "Kundenliste.xlsx") ' Dim attachment As Attachment = New Attachment(File.OpenRead(excel), "Kundenliste.xlsx")
' Msg.Attachments.Add(attachment) ' Msg.Attachments.Add(attachment)
If String.IsNullOrEmpty(mailto) = False AndAlso String.IsNullOrEmpty(Betreff) = False AndAlso String.IsNullOrEmpty(htmlbody) = False Then If String.IsNullOrEmpty(mailto) = False AndAlso String.IsNullOrEmpty(Betreff) = False AndAlso String.IsNullOrEmpty(htmlbody) = False Then
@@ -688,7 +688,7 @@ Partial Class ForgotPW
lblMessage.Text = "Error02: Mail not delivered!" lblMessage.Text = "Error02: Mail not delivered!"
'MsgBox("Error02: Mail not delivered!" & vbCrLf & "New Token has been generated.") 'MsgBox("Error02: Mail not delivered!" & vbCrLf & "New Token has been generated.")
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokenname = genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID) tokenname = Await genToken(username, password, email, customerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID)
Session.Add("TokenforEmail", tokenname) Session.Add("TokenforEmail", tokenname)
Session.Add("USerID", customerID) Session.Add("USerID", customerID)
Else Else
@@ -708,16 +708,17 @@ Partial Class ForgotPW
End If End If
End Function End Function
Function genToken(username As String, password As String, email As String, CustomerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, isnewSession As Boolean, theUserID As String) As String Async Function genToken(username As String, password As String, email As String, CustomerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, isnewSession As Boolean, theUserID As String) As Task(Of String)
If isnewSession = False Then If isnewSession = False Then
Dim time() As Byte = BitConverter.GetBytes(DateTime.UtcNow.ToBinary()) Dim time() As Byte = BitConverter.GetBytes(DateTime.UtcNow.ToBinary())
Dim Key() As Byte = Guid.NewGuid().ToByteArray() Dim Key() As Byte = Guid.NewGuid().ToByteArray()
Dim token As String Dim token As String = String.Empty
If isusrnmright = True And iscstmIDright = True And isemailright = True AndAlso String.IsNullOrEmpty(theUserID) = False Then If isusrnmright = True And iscstmIDright = True And isemailright = True AndAlso String.IsNullOrEmpty(theUserID) = False Then
Try
token = VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(Convert.ToBase64String(time.Concat(Key).ToArray())) token = VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(Convert.ToBase64String(time.Concat(Key).ToArray()))
If Not String.IsNullOrEmpty(token) Then
Return token Return token
Catch Ex As Exception Else
'Dim Msg, Style, Title As String 'Dim Msg, Style, Title As String
'Msg = "Token Generation failed" & vbCrLf & "A new E-mail has been sent to the intern e-mail given." 'Msg = "Token Generation failed" & vbCrLf & "A new E-mail has been sent to the intern e-mail given."
'Style = vbRetry + vbExclamation + vbDefaultButton1 'Style = vbRetry + vbExclamation + vbDefaultButton1
@@ -726,7 +727,8 @@ Partial Class ForgotPW
'If MsgBox(Msg, Style, Title).Retry Then 'If MsgBox(Msg, Style, Title).Retry Then
'genToken(username, password, email) 'genToken(username, password, email)
token = VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(Convert.ToBase64String(time.Concat(Key).ToArray())) token = VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(Convert.ToBase64String(time.Concat(Key).ToArray()))
If SendEmail(username, password, email, token, CustomerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID) = True Then Dim boolemailsent As Boolean = Await SendEmail(username, password, email, token, CustomerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID)
If boolemailsent = True Then
'MsgBox("Email could not been sent because of an internal encryption error.", vbOK + vbInformation + vbDefaultButton1, "Token-Generation Error") 'MsgBox("Email could not been sent because of an internal encryption error.", vbOK + vbInformation + vbDefaultButton1, "Token-Generation Error")
Else Else
'MsgBox("Email has been sent successful." & vbCr & "Please check your E-Mails!", vbOK + vbInformation + vbDefaultButton1, "Token-Generation successful!") 'MsgBox("Email has been sent successful." & vbCr & "Please check your E-Mails!", vbOK + vbInformation + vbDefaultButton1, "Token-Generation successful!")
@@ -739,13 +741,13 @@ Partial Class ForgotPW
If jetzt < wenn Then If jetzt < wenn Then
Return "NotYet" Return "NotYet"
Else Else
token = genToken(username, password, email, CustomerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID) token = Await genToken(username, password, email, CustomerID, isusrnmright, iscstmIDright, isemailright, Session.IsNewSession, theUserID)
Return token Return token
'End If 'End If
End If End If
End Try End If
Else Else
Return String.Empty Return String.Empty
End If End If
Else Else
Return "Error in Session ID. It has changed. Please check admin!" Return "Error in Session ID. It has changed. Please check admin!"
@@ -760,7 +762,7 @@ Partial Class ForgotPW
Return min + (max - min) * (one_byte(0) / 255) Return min + (max - min) * (one_byte(0) / 255)
End Function End Function
Function gensaltToken(username As String, password As String, email As String, CustomerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, isnewSession As Boolean, theUserID As String, intz As Integer) As String Async Function gensaltToken(username As String, password As String, email As String, CustomerID As String, isusrnmright As Boolean, iscstmIDright As Boolean, isemailright As Boolean, isnewSession As Boolean, theUserID As String, intz As Integer) As Task(Of String)
If isnewSession = False Then If isnewSession = False Then
Dim time() As Byte = BitConverter.GetBytes(DateTime.UtcNow.ToBinary()) Dim time() As Byte = BitConverter.GetBytes(DateTime.UtcNow.ToBinary())
Dim Key() As Byte = Guid.NewGuid().ToByteArray() Dim Key() As Byte = Guid.NewGuid().ToByteArray()
@@ -773,7 +775,7 @@ Partial Class ForgotPW
'Dim tok As Byte = Convert.ToBase64String(time.Concat(Key).ToArray()) 'Dim tok As Byte = Convert.ToBase64String(time.Concat(Key).ToArray())
Dim tok As String = Convert.ToBase64String(time.Concat(Key).ToArray()) Dim tok As String = Convert.ToBase64String(time.Concat(Key).ToArray())
token = VERAG_VARIABLES.HashPassword(tok, VERAG_VARIABLES.GenerateSalt(intz), intzahliterats, intzahl) token = Await VERAG_VARIABLES.HashPasswordAsync(tok, VERAG_VARIABLES.GenerateSalt(intz), intzahliterats, intzahl)
Return Convert.ToBase64String(token) Return Convert.ToBase64String(token)
Else Else
@@ -822,6 +824,54 @@ Partial Class ForgotPW
Return True Return True
End If End If
End Function End Function
Async Function getDateoftokenAsync(tokenname As String) As Task(Of Boolean)
Dim data() As Byte = Convert.FromBase64String(VERAG_PROG_ALLGEMEIN.cCryptography3.Decrypt(tokenname))
Dim wenn As DateTime = DateTime.FromBinary(BitConverter.ToInt64(data, 0))
Dim nameoftoken = VERAG_PROG_ALLGEMEIN.cCryptography3.Decrypt(tokenname)
Dim niteras As Integer = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 7))
Dim nzrand As Integer = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 4), Math.Pow(2, 10))
Dim newsalt As Byte() = VERAG_VARIABLES.GenerateSalt(nzrand)
Dim newhash As Byte() = Await VERAG_VARIABLES.HashPasswordAsync(tokenname, newsalt, niteras, nzrand)
If wenn < DateTime.UtcNow.AddMinutes(-30) And Await VERAG_VARIABLES.VerifyhashAsync(tokenname, salt, newhash, niteras, nzrand) = True Then
nameoftoken = String.Empty
tokenname = nameoftoken
'MsgBox("Token has not been found or is too old!" + Environment.NewLine + "Please send a new E-mail!")
If String.IsNullOrEmpty(txtEmail.Text) And String.IsNullOrEmpty(txt_CustomerID.Text) And String.IsNullOrEmpty(txt_Username.Text) Then
lblMessage.Text = "Token has not been found or is too old!" + Environment.NewLine + "Please send a new E-mail!"
ElseIf String.IsNullOrEmpty(txtEmail_M.Text) And String.IsNullOrEmpty(txt_CustomerID_M.Text) And String.IsNullOrEmpty(txt_Username_M.Text) Then
lblMessage_M.Text = "Token has not been found or is too old!" + Environment.NewLine + "Please send a new E-mail!"
End If
Session.Remove("TokenforEmail")
Return True
ElseIf nameoftoken = "Error04" Then
nameoftoken = String.Empty
tokenname = nameoftoken
Session.Remove("TokenforEmail")
Return True
ElseIf nameoftoken = "NotYet" Then
Return True
ElseIf nameoftoken = "Error in Session ID. It has changed. Please check admin!" Then
' Dim mailto As String = "support@verag.ag"
Dim mailto As String = "ja@verag.ag"
Dim htmlbody As String = String.Empty
VERAG_VARIABLES.seterrorcount(500)
Dim Betreff As String = "Session ID" + VERAG_VARIABLES.geterrornumb
If String.IsNullOrEmpty(txt_Username.Text) = False And String.IsNullOrEmpty(txt_Username_M.Text) = True Then
htmlbody = "<p> Der User " + txt_Username.Text + "hat eine ungültige oder geänderte Session-ID </p> <table><th><td>User</td></th><th><td>neue ID</td></th><tr><td>" + txt_Username.Text + "</td><td>" + Session.SessionID + "</td></tr></table>"
ElseIf String.IsNullOrEmpty(txt_Username_M.Text) = False And String.IsNullOrEmpty(txt_Username.Text) = True Then
htmlbody = "<p> Der User " + txt_Username_M.Text + "hat eine ungültige oder geänderte Session-ID </p> <table><th><td>User</td></th><th><td>neue ID</td></th><tr><td>" + txt_Username_M.Text + "</td><td>" + Session.SessionID + "</td></tr></table>"
End If
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody)
Return False
Else
Return True
End If
End Function
Function RandomString(r As Random, max As Integer) As String Function RandomString(r As Random, max As Integer) As String
Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!§$%&/?=" Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!§$%&/?="
@@ -834,30 +884,30 @@ Partial Class ForgotPW
Return sb.ToString() Return sb.ToString()
End Function End Function
Protected Sub btn_Testmail_Click(sender As Object, e As EventArgs) Protected Async Sub btn_Testmail_Click(sender As Object, e As EventArgs)
Dim username As String = "userwithlongername" Dim username As String = "userwithlongername"
Dim Passw As String = "Test1!W" Dim Passw As String = "Test1!W"
Dim email As String = "ja@verag.ag" Dim email As String = "ja@verag.ag"
Dim CustomerID As String = "717585" Dim CustomerID As String = "717585"
Dim TheusrID As String = "3" Dim TheusrID As String = "3"
Dim tokentest As String = genToken(username, Passw, email, CustomerID, True, True, True, False, TheusrID) Dim tokentest As String = Await genToken(username, Passw, email, CustomerID, True, True, True, False, TheusrID)
Dim hashtoken As Byte() Dim hashtoken As Byte()
Dim iterationnumb As Integer = VERAG_VARIABLES.getiterationnumber Dim iterationnumb As Integer = VERAG_VARIABLES.getiterationnumber
Dim intzahl1 As Integer = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10)) Dim intzahl1 As Integer = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10))
'MsgBox(salttoken) 'MsgBox(salttoken)
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokentest = genToken(username, Passw, email, CustomerID, True, True, True, False, TheusrID) tokentest = Await genToken(username, Passw, email, CustomerID, True, True, True, False, TheusrID)
Session.Add("TokenforEmail", tokentest) Session.Add("TokenforEmail", tokentest)
Session.Add("SessID", VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(Session.SessionID)) Session.Add("SessID", VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(Session.SessionID))
Else Else
tokentest = Session.Item("TokenforEmail") tokentest = Session.Item("TokenforEmail")
End If End If
salt = VERAG_VARIABLES.GenerateSalt(intzahl1) salt = VERAG_VARIABLES.GenerateSalt(intzahl1)
hashtoken = VERAG_VARIABLES.HashPassword(tokentest, salt, iterationnumb, intzahl1) hashtoken = Await VERAG_VARIABLES.HashPasswordAsync(tokentest, salt, iterationnumb, intzahl1)
If VERAG_VARIABLES.Verifyhash(tokentest, salt, hashtoken, iterationnumb, intzahl1) = True Then If Await VERAG_VARIABLES.VerifyhashAsync(tokentest, salt, hashtoken, iterationnumb, intzahl1) = True Then
If SendEmail(username, Passw, email, tokentest, CustomerID, True, True, True, False, TheusrID) = True Then If Await SendEmail(username, Passw, email, tokentest, CustomerID, True, True, True, False, TheusrID) = True Then
'password = RandomString(New Random, 10) 'password = RandomString(New Random, 10)
If getDateoftoken(tokentest) = True Then If Await getDateoftokenAsync(tokentest) = True Then
'Dim msgboxstyle = vbDefaultButton1 + vbOK 'Dim msgboxstyle = vbDefaultButton1 + vbOK
'MsgBox(tokenname, msgboxstyle) 'MsgBox(tokenname, msgboxstyle)
lblMessage_M.ForeColor = Color.Green lblMessage_M.ForeColor = Color.Green
@@ -870,7 +920,7 @@ Partial Class ForgotPW
'MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!") 'MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!")
If Session.Item("TokenforEmail") = Nothing Then If Session.Item("TokenforEmail") = Nothing Then
tokentest = genToken(username, Passw, email, CustomerID, True, True, True, False, TheusrID) tokentest = Await genToken(username, Passw, email, CustomerID, True, True, True, False, TheusrID)
Session.Add("TokenforEmail", tokentest) Session.Add("TokenforEmail", tokentest)
Else Else
tokentest = Session.Item("TokenforEmail") tokentest = Session.Item("TokenforEmail")

View File

@@ -9,18 +9,92 @@ Partial Class login_FLEX
Private USERID As String = String.Empty Private USERID As String = String.Empty
Private salt As Byte() Private salt As Byte()
Private intzahl As Integer Private intzahl As Integer
Private intzahliterats As Integer Public intzahliterats As Integer = -1
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Protected Async Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
VERAG_VARIABLES.initerrorcount() VERAG_VARIABLES.initerrorcount()
If Page.IsPostBack = True Then If Page.IsPostBack = True Then
Page.MaintainScrollPositionOnPostBack = True Page.MaintainScrollPositionOnPostBack = True
intzahliterats = VERAG_VARIABLES.getiterationnumber intzahliterats = VERAG_VARIABLES.getiterationnumber
Else Else
Try
Dim teststr = String.Empty
intzahliterats = 4
teststr = Await TestPerformance.TestHashrateServerAsync(VERAG_VARIABLES.RandomInteger(2, Math.Pow(2, 2)))
If String.Equals(teststr, String.Empty) = False Then
intzahliterats = VERAG_VARIABLES.getiterationnumber
End If
Catch Ex As SettingsPropertyNotFoundException
VERAG_VARIABLES.seterrorcount(4534)
intzahliterats = 0
Response.Write(VERAG_VARIABLES.geterrornumb() + "Error on Tests for login! Try again!")
VERAG_VARIABLES.seterrorcount(4232)
sendmail("ja@verag.ag", Session.IsNewSession, VERAG_VARIABLES.geterrornumb)
End Try
Page.MaintainScrollPositionOnPostBack = False Page.MaintainScrollPositionOnPostBack = False
End If End If
End Sub End Sub
Protected Sub ValidateUser(sender As Object, e As EventArgs)
Public Shared Sub sendmail(emailTo As String, sessionright As Boolean, errornumb As String)
Dim getdomianenvironment As String = String.Empty
Dim pagename As String = String.Empty
Dim ServPort As String = String.Empty
Dim mailto As String = String.Empty
Dim Betreff As String = String.Empty
Dim htmlbody As String = String.Empty
Dim emailnr = VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA_ID.ToString
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
'MsgBox(getdomianenvironment)
getdomianenvironment = HttpContext.Current.Request.ServerVariables("SERVER_NAME")
ServPort = ":" + HttpContext.Current.Request.ServerVariables("SERVER_PORT")
'pagename = Request.ServerVariables("SCRIPT_NAME")
mailto = emailTo
Betreff = "Passwort reset"
Dim mailpic As String = "<image src=" + "../images/VERAG_AEO_MailSig.jpg" + ">"
Dim Ausschusstext As String = "Wir arbeiten ausschließlich auf Grund der Allgemeinen Spediteurbedingungen in der jeweils geltenden Fassung. Zahlungen werden zunächst auf Frachten, Spesen"
Dim Ausschusstext2 As String = "und Zinsen zuletzt auf Zölle angerechnet. Zahlbar und klagbar in Schärding oder Ried. Steuer-Zoll-und Tarifauskünfte sind unverbindlich."
Dim Ausschusstext3 As String = "We operate exclusively on the basis of the General Freight Forwarding Terms and Conditions in the respectively applicable version. Payments are initially"
Dim Ausschusstext4 As String = "charged on freight, fees and interests and at last on customs duties. The place of jurisdiction: Schärding / Ried. Tax, customs and tariff information are not binding."
htmlbody = String.Format("Auf der Seite <a runat=" + "server" + " href=http://" + getdomianenvironment + "/login/Customers/login_FLEX.aspx> http: //" + getdomianenvironment + "/login/Customers/login_FLEX.aspx </a> trat der Fehler " + errornumb + "auf. Bitte Logs anschauen." + Environment.NewLine + "<br /><br />Notice:<br /><span style='color: #043381;font-size:14px'><i>The Link is valid for 30 minutes until" + Space(1) + Date.Now.AddMinutes(30).ToString() + Space(1) + "only!</i></span><br / >To resend the E-Mail: <a runat=" + "server" + " href=http://" + getdomianenvironment + "/login/ForgotPW.aspx>Follow this Link</a><br />Kind regards, <br /><span style='color: #043381'><b>VERAG | EDV Support</b></span><br /><span>" + mailpic + "</span><br /><span style='color: #043381'>VERAG Spedition AG | A 4975 Suben, Nr. 100</span><br /><span style='color: #043381'>T.<a href='tel:+43 7711 2777-xx'>+43 7711 2777-xx</a> |<a href='mailto:@support@verag.ag'>support@verag.ag</a> | " + emailnr + "FN xxxxxxx</span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext + "</i></span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext2 + "</i></span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext3 + "</i></span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext4 + "</i></span><br />")
ElseIf String.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables("SERVER_NAME")) = False Then
getdomianenvironment = HttpContext.Current.Request.ServerVariables("SERVER_NAME")
'MsgBox(getdomianenvironment)
ServPort = ":" + HttpContext.Current.Request.ServerVariables("SERVER_PORT")
'pagename = Request.ServerVariables("SCRIPT_NAME")
mailto = emailTo
Betreff = "Passwort reset"
Dim mailpic As String = "<image src=" + "../images/VERAG_AEO_MailSig.jpg" + ">"
Dim Ausschusstext As String = "Wir arbeiten ausschließlich auf Grund der Allgemeinen Spediteurbedingungen in der jeweils geltenden Fassung. Zahlungen werden zunächst auf Frachten, Spesen"
Dim Ausschusstext2 As String = "und Zinsen zuletzt auf Zölle angerechnet. Zahlbar und klagbar in Schärding oder Ried. Steuer-Zoll-und Tarifauskünfte sind unverbindlich."
Dim Ausschusstext3 As String = "We operate exclusively on the basis of the General Freight Forwarding Terms and Conditions in the respectively applicable version. Payments are initially"
Dim Ausschusstext4 As String = "charged on freight, fees and interests and at last on customs duties. The place of jurisdiction: Schärding / Ried. Tax, customs and tariff information are not binding."
htmlbody = String.Format("Auf der Seite <a runat=" + "server" + " href=http://" + getdomianenvironment + "/login/Customers/login_FLEX.aspx> http: //" + getdomianenvironment + "/login/Customers/login_FLEX.aspx </a> trat der Fehler " + errornumb + "auf. Bitte Logs anschauen." + Environment.NewLine + "<br /><br />Notice:<br /><span style='color: #043381;font-size:14px'><i>The Link is valid for 30 minutes until" + Space(1) + Date.Now.AddMinutes(30).ToString() + Space(1) + "only!</i></span><br / >To resend the E-Mail: <a runat=" + "server" + " href=http://" + getdomianenvironment + "/login/ForgotPW.aspx>Follow this Link</a><br />Kind regards, <br /><span style='color: #043381'><b>VERAG | EDV Support</b></span><br /><span>" + mailpic + "</span><br /><span style='color: #043381'>VERAG Spedition AG | A 4975 Suben, Nr. 100</span><br /><span style='color: #043381'>T.<a href='tel:+43 7711 2777-xx'>+43 7711 2777-xx</a> |<a href='mailto:@support@verag.ag'>support@verag.ag</a> | " + emailnr + "FN xxxxxxx</span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext + "</i></span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext2 + "</i></span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext3 + "</i></span><br /><span style='color: #043381;font-size:12px'><i>" + Ausschusstext4 + "</i></span><br />")
ElseIf String.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables("SERVER_NAME")) = True Then
'MsgBox("Error09:" + Environment.NewLine + "The Domain could not be vaildated. Check Link please or contact the Administrator of the program.")
End If
'Dim pg As String = Request.ServerVariables("URL")
'MsgBox("/" + ServPort + Request.ServerVariables("URL"))
Try
'Dim Strtemp = Session.Keys.Item("urltochangepw")
' Msg.Attachments.Add(attachment)
If String.IsNullOrEmpty(mailto) = False AndAlso String.IsNullOrEmpty(Betreff) = False AndAlso String.IsNullOrEmpty(htmlbody) = False Then
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody)
Else
VERAG_VARIABLES.seterrorcount(7)
'lblMessage_M.Text = VERAG_VARIABLES.geterrornumb + "The form has not been filled out completely."
End If
' lblMessage_M.ForeColor = Color.Green
'lblMessage_M.Text = "Success" + Environment.NewLine + "The Password-Reset-Link has been mailed to the valid Address given."
'MsgBox("SENT")
Catch ex As Exception
'MsgBox(Err.Number & ex.Message & ex.StackTrace.ToString) 'Falls ein Fehler auftritt wird eine MsgBox angezeigt
End Try
End Sub
Protected Async Sub ValidateUser(sender As Object, e As EventArgs)
Dim ConnectionString = "" Dim ConnectionString = ""
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True
@@ -116,7 +190,7 @@ Partial Class login_FLEX
reqfieldvalpassw.Validate() reqfieldvalpassw.Validate()
If reqfieldvalpassw.IsValid = True Then If reqfieldvalpassw.IsValid = True Then
intzahl = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10)) intzahl = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10))
Dim hashpw1 As Byte() = VERAG_VARIABLES.HashPassword(tb3.Text, salt, intzahliterats, intzahl) Dim hashpw1 As Byte() = Await VERAG_VARIABLES.HashPasswordAsync(tb3.Text, salt, intzahliterats, intzahl)
passw = tb3.Text passw = tb3.Text
End If End If
End If End If
@@ -125,9 +199,8 @@ Partial Class login_FLEX
reqfieldvalpassw_M.Enabled = True reqfieldvalpassw_M.Enabled = True
reqfieldvalpassw_M.Validate() reqfieldvalpassw_M.Validate()
intzahl = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10)) intzahl = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10))
Dim hashpw1_M As Byte() = VERAG_VARIABLES.HashPassword(tb3_M.Text, salt, intzahliterats, intzahl)
If reqfieldvalpassw_M.IsValid = True Then If reqfieldvalpassw_M.IsValid = True Then
Dim hashpw_M As Byte() = VERAG_VARIABLES.HashPassword(tb3_M.Text, salt, intzahliterats, intzahl) Dim hashpw_M As Byte() = Await VERAG_VARIABLES.HashPasswordAsync(tb3_M.Text, salt, intzahliterats, intzahl)
passw = tb3_M.Text passw = tb3_M.Text
Else Else
VERAG_VARIABLES.seterrorcount(4) VERAG_VARIABLES.seterrorcount(4)
@@ -175,8 +248,8 @@ Partial Class login_FLEX
If String.Equals(tb3.Text, dr("Password")) = True Then If String.Equals(tb3.Text, dr("Password")) = True Then
intzahl = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10)) intzahl = VERAG_VARIABLES.RandomInteger(Math.Pow(2, 6), Math.Pow(2, 10))
salt = VERAG_VARIABLES.GenerateSalt(intzahl) salt = VERAG_VARIABLES.GenerateSalt(intzahl)
Dim hashpw As Byte() = VERAG_VARIABLES.HashPassword(passw, salt, intzahliterats, intzahl) Dim hashpw As Byte() = Await VERAG_VARIABLES.HashPasswordAsync(passw, salt, intzahliterats, intzahl)
If VERAG_VARIABLES.Verifyhash(dr("Password").ToString, salt, hashpw, intzahliterats, intzahl) = True Then If Await VERAG_VARIABLES.VerifyhashAsync(dr("Password").ToString, salt, hashpw, intzahliterats, intzahl) = True Then
passw = dr("Password").ToString passw = dr("Password").ToString
Else Else
passw = String.Empty passw = String.Empty