Platforms to show: All Mac Windows Linux Cross-Platform

/Encryption/Argon2 Password Hashing


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/Argon2 Password Hashing

This example is the version from Thu, 31th Aug 2016.

Project "Argon2 Password Hashing.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim a as new Argon2MBS a.OutputLength = 24 a.Password = "password" a.Salt = "somesalt" a.cost = 2 a.MemoryCost = 65536 a.Lanes = 4 a.Threads = 4 dim hash as string = a.Calc(a.kTypeI) dim t as string = EncodeHex(hash) if t = "45d7ac72e76f242b20b77b9bf9bf9d5915894e669a24e6c6" then // ok else // failed Break end if dim h as string = DecodeHex("45d7ac72e76f242b20b77b9bf9bf9d5915894e669a24e6c6") if a.Verify(h, a.kTypeI) then // ok else // failed break end if End EventHandler
End Class
Class HashWindow Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control PasswordField Inherits TextField
ControlInstance PasswordField Inherits TextField
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control SaltField Inherits TextField
ControlInstance SaltField Inherits TextField
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control SecretField Inherits TextField
ControlInstance SecretField Inherits TextField
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control ADField Inherits TextField
ControlInstance ADField Inherits TextField
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control CostField Inherits TextField
ControlInstance CostField Inherits TextField
End Control
Control Label6 Inherits Label
ControlInstance Label6 Inherits Label
End Control
Control MemoryField Inherits TextField
ControlInstance MemoryField Inherits TextField
End Control
Control Label7 Inherits Label
ControlInstance Label7 Inherits Label
End Control
Control LanesField Inherits TextField
ControlInstance LanesField Inherits TextField
End Control
Control Label8 Inherits Label
ControlInstance Label8 Inherits Label
End Control
Control ThreadsField Inherits TextField
ControlInstance ThreadsField Inherits TextField
End Control
Control Label9 Inherits Label
ControlInstance Label9 Inherits Label
End Control
Control VersionPopupMenu Inherits PopupMenu
ControlInstance VersionPopupMenu Inherits PopupMenu
End Control
Control hashfield Inherits TextArea
ControlInstance hashfield Inherits TextArea
End Control
Control Label10 Inherits Label
ControlInstance Label10 Inherits Label
End Control
Control CalcButton Inherits PushButton
ControlInstance CalcButton Inherits PushButton
EventHandler Sub Action() dim a as new Argon2MBS set a dim hash as string = a.Calc(a.kTypeI) dim t as string = EncodeHex(hash) hashfield.text = t End EventHandler
End Control
Control VerifyButton Inherits PushButton
ControlInstance VerifyButton Inherits PushButton
EventHandler Sub Action() dim a as new Argon2MBS set a dim d as string = DecodeHex(hashfield.Text) if a.verify(d, a.kTypeI) then MsgBox "OK" else if a.LastError = 0 then MsgBox "Failed" else MsgBox a.LastErrorMessage end if end if End EventHandler
End Control
Control Label11 Inherits Label
ControlInstance Label11 Inherits Label
End Control
Control OutputField Inherits TextField
ControlInstance OutputField Inherits TextField
End Control
Sub set(a as Argon2MBS) a.AssociatedData = ConvertEncoding(ADField.Text, Encodings.UTF8) a.Secret = ConvertEncoding(SecretField.Text, Encodings.UTF8) a.Password = ConvertEncoding(PasswordField.Text, Encodings.UTF8) a.Salt = ConvertEncoding(SaltField.Text, Encodings.UTF8) a.OutputLength = val(OutputField.Text) a.MemoryCost = val(MemoryField.Text) a.Threads = val(ThreadsField.Text) a.Lanes = val(LanesField.Text) a.Cost = val(CostField.Text) if VersionPopupMenu.ListIndex = 0 then a.Version = a.kVersion10 else a.Version = a.kVersion13 end if End Sub
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
End Project

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


The biggest plugin in space...