Platforms to show: All Mac Windows Linux Cross-Platform

/Encryption/ECKey/ECKey Client


Required plugins for this example: MBS Encryption Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Encryption/ECKey/ECKey Client

This example is the version from Mon, 27th Dec 2020.

Project "ECKey Client.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class ClientWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() sock = New ClientSocket sock.List = list sock.port = 9999 sock.Address = "localhost" sock.Connect End EventHandler
Property sock As ClientSocket
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class ClientSocket Inherits TCPSocket
EventHandler Sub Connected() Log "ClientSocket Connected to "+Me.RemoteAddress Dim EC_Curve_ID As Integer = 415 // NID_X9_62_prime256v1 // on Client dhc = New ECDHEMBS(EC_Curve_ID) PublicKey = dhc.PublicKey // send public key to other side Me.Write PublicKey End EventHandler
EventHandler Sub DataAvailable() Dim data As String = Me.ReadAll If bf = Nil Then // setup encryption // on Client Dim secret As String = dhc.DeriveSecretKey(data) bf = New BlowfishMBS bf.SetKey secret EncryptionInitialized = True Else data = bf.DecryptCFB64(data, tempd) Process data End If End EventHandler
EventHandler Sub Error() Log "ClientSocket error: "+Str(me.LastErrorCode) End EventHandler
Sub Process(data as string) // do something useful here for data you got. Log "Received: "+data Dim now As New date Me.Write now.SQLDateTime+" at client" End Sub
Sub Write(data as string) // if we have encryption, apply it If bf <> Nil Then data = bf.EncryptCFB64(data, tempe) End If // Calling the overridden superclass method. Super.Write data End Sub
Sub log(s as string) list.AddRow s End Sub
Property EncryptionInitialized As Boolean
Property PublicKey As string
Property bf As BlowfishMBS
Property dhc As ECDHEMBS
Property list As listbox
Property tempd As MemoryBlock
Property tempe As MemoryBlock
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Encryption Plugin.


The biggest plugin in space...