Sub bttn_Register_Click
Dim bc As BCrypt
Dim uname As String = txt_EmailLogin.Text.Trim
Dim pwd As String = txt_LoginPassword.Text.Trim
' hash password
Dim salt As String = bc.gensalt
Dim hashed As String = bc.hashpw(pwd,salt)
Dim strData As String
Dim parser As JSONParser
' attempt register at site
Dim http As HttpJob
Dim param As Map = CreateMap("email":uname,"pwd":hashed,"test":"thisisatest")
Dim json As String
Dim jgen As JSONGenerator
jgen.Initialize(param)
json = jgen.ToString
Log(salt)
Log(hashed)
Log(json)
http.Initialize("",Me)
http.PostString("http://127.0.0.1:51042/register",json)
wait for (http) JobDone(http As HttpJob)
If http.Success Then
strData = http.GetString
Log("strData=" & strData)
parser.Initialize(strData)
Dim Map1 As Map = parser.NextObject
If Map1.Get("success") Then
Log("success")
' B4XPages.ClosePage(Me)
Else
Log("errorMessage=" & Map1.Get("errorMessage"))
Return
End If
Else
Log("Http job not success")
End If
End Sub