You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Encryption/Blowfish CBC
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
Control TextField2 Inherits TextField
ControlInstance TextField2 Inherits TextField
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
dim m as memoryblock // temporary storage of current state
dim plain as string = TextField1.text
dim b as new BlowfishMBS
b.SetKey "EinKey1234567890" // some key
// make sure it has a defined decoding
plain = ConvertEncoding(plain, Encodings.UTF8)
// add chr(0) padding:
while lenb(plain) mod 8 <> 0
plain = plain + chrb(0)
wend
dim Encrypted as string = b.EncryptCBC(plain,m)
dim EncryptedBase64 as string = EncodeBase64(Encrypted)
TextField2.Text = EncryptedBase64
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
dim EncryptedBase64 as string = TextField2.Text
dim Encrypted as string = DecodeBase64(EncryptedBase64)
dim m as MemoryBlock = nil
dim b as new BlowfishMBS
b.SetKey "EinKey1234567890" // some key
dim t1 as string = b.DecryptCBC(Encrypted,m)
// remove chr(0) padding
while lenb(t1)>0 and ascb(Rightb(t1,1)) = 0
t1 = leftb(t1, lenb(t1)-1)
wend
// set encoding
t1 = DefineEncoding(t1, encodings.UTF8)
// show it
TextField3.Text = t1
End EventHandler
End Control
Control TextField3 Inherits TextField
ControlInstance TextField3 Inherits TextField
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar