Example: /Encryption/AES with PHP/AES with PHP

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Encryption/AES with PHP/AES with PHP


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/AES with PHP/AES with PHP

This example is the version from Mon, 14th Aug 2016.

Project "AES with PHP.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim keyPlainText as string = "Hello" dim ivPlainText as string = "test" dim dataPlaintext as string = "Just a test message. äöü" dim algorithm as string = "aes-256-cbc" // make sure we use UTF-8 keyPlainText = keyPlainText.DefineEncoding(encodings.UTF8) ivPlainText = ivPlainText.DefineEncoding(encodings.UTF8) dataPlaintext = dataPlaintext.DefineEncoding(encodings.UTF8) // init dim c as CipherMBS = CipherMBS.CipherByName(algorithm) dim ivLength as integer = c.IVLength dim keyHash as string = SHA256MBS.Hash(keyPlainText) dim ivHash as string = SHA256MBS.Hash(ivPlainText) dim IV as string = leftb(ivHash, ivLength) // encrypt call c.EncryptInit keyHash, IV dim EncryptedData as string = c.ProcessString(dataPlaintext) + c.FinalizeAsString dim database64 as string = EncodeBase64(EncryptedData, 0) MsgBox "Key: "+EncodeHex(keyHash)+EndOfLine+_ "IV: "+EncodeHex(IV)+EndOfLine+_ "Data: "+database64 // decrypt call c.DecryptInit keyHash, IV dim DecryptedData as string = c.ProcessString(EncryptedData) + c.FinalizeAsString DecryptedData = DefineEncoding(DecryptedData, encodings.UTF8) MsgBox DecryptedData End EventHandler
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.


💬 Ask a question or report a problem