Änderungen Algorithmus Serverlast senken und Produktivität steigern. Und GUI Anpassungen Mobil.

This commit is contained in:
ja
2021-12-03 15:34:56 +01:00
parent 39e94f95b7
commit d833a5dcff
5 changed files with 51 additions and 33 deletions

View File

@@ -4,7 +4,7 @@ Imports Konscious.Security.Cryptography
Public Class VERAG_VARIABLES
Public Shared errornumb As Integer = 0
Shared Function getiterationnumber() As Integer
Return RandomInteger(Math.Pow(2, 2), Math.Pow(2, 8))
Return RandomInteger(Math.Pow(2, 4), Math.Pow(2, 11))
End Function
Shared Sub initerrorcount()
@@ -28,17 +28,27 @@ Public Class VERAG_VARIABLES
'Convert.ToBase64String(saltBytes)
End Function
Public Shared Async Function HashPassword(ByVal password As String, ByVal salt As Byte(), ByVal nIterations As Integer, ByVal nHash As Integer) As Threading.Tasks.Task(Of Byte())
Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(password))
Argon.Salt = salt
Argon.DegreeOfParallelism = 4
Argon.Iterations = nIterations
Argon.MemorySize = 4096
Return Await Argon.GetBytesAsync(nHash)
'Return Convert.ToBase64String(Argon.GetBytes(nHash))
Return Argon.GetBytes(nHash)
'Dim saltBytes = Convert.FromBase64String(salt)
'Using rfc2898DeriveBytes = New Rfc2898DeriveBytes(password, saltBytes, nIterations)
'End Using
'Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(password))
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
Dim Argon As Argon2d = New Argon2d(Encoding.UTF8.GetBytes(password))
Argon.Salt = salt
Argon.DegreeOfParallelism = 24
Argon.Iterations = nIterations
Argon.MemorySize = (nIterations / 1.05) + 1 * 150
Return Await Argon.GetBytesAsync(nHash)
'Return Convert.ToBase64String(Argon.GetBytes(nHash))
'Return Argon.GetBytes(nHash)
'Dim saltBytes = Convert.FromBase64String(salt)
'Using rfc2898DeriveBytes = New Rfc2898DeriveBytes(password, saltBytes, nIterations)
'End Using
Else
Dim Argon As Argon2d = New Argon2d(Encoding.UTF8.GetBytes(password))
Argon.Salt = salt
Argon.DegreeOfParallelism = 36
Argon.Iterations = nIterations
Argon.MemorySize = (nIterations / 0.385) + 1 * 250
Return Await Argon.GetBytesAsync(nHash)
End If
End Function
Public Shared Async Function Verifyhash(ByVal passw As String, ByVal salt As Byte(), ByVal hash As Byte(), ByVal nIterations As Integer, ByVal nHash As Integer) As Threading.Tasks.Task(Of Boolean)