Platforms to show: All Mac Windows Linux Cross-Platform
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/SHA/SHA3 Test
This example is the version from Mon, 9th Nov 2014.
Project "SHA3 Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open()
test(224, "", "f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd")
test(256, "", "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
test(384, "", "2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff")
test(512, "", "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e")
test(224, "The quick brown fox jumps over the lazy dog", "310aee6b30c47350576ac2873fa89fd190cdc488442f3ef654cf23fe")
test(224, "The quick brown fox jumps over the lazy dog.", "c59d4eaeac728671c635ff645014e2afa935bebffdb5fbd207ffdeab")
test(256, "The quick brown fox jumps over the lazy dog", "4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15")
test(256, "The quick brown fox jumps over the lazy dog.", "578951e24efd62a3d63a86f7cd19aaa53c898fe287d2552133220370240b572d")
test(384, "The quick brown fox jumps over the lazy dog", "283990fa9d5fb731d786c5bbee94ea4db4910f18c62c03d173fc0a5e494422e8a0b3da7574dae7fa0baf005e504063b3")
test(384, "The quick brown fox jumps over the lazy dog.", "9ad8e17325408eddb6edee6147f13856ad819bb7532668b605a24a2d958f88bd5c169e56dc4b2f89ffd325f6006d820b")
test(512, "The quick brown fox jumps over the lazy dog", "d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609")
test(512, "The quick brown fox jumps over the lazy dog.", "ab7192d2b11f51c7dd744e7b3441febf397ca07bf812cceae122ca4ded6387889064f8db9230f173f6d1ab6e24b6e50f065b039f799f5592360a6558eb52d760")
List.addrow "OK"
End EventHandler
Sub Test(n as integer, input as string, output as string)
dim Rate as integer
dim capacity as integer
dim outputLength as integer
List.AddRow str(n)
List.AddRow input
Select case n
case 224
rate = 1152
capacity = 448
outputLength = 224/8
case 256
rate = 1088
capacity = 512
outputLength = 256/8
case 384
rate = 832
capacity = 768
outputLength = 384/8
case 512
rate = 576
capacity = 1024
outputLength = 512/8
else
break
// missing
// Default parameters, arbitrary length output
rate = 1024
capacity = 576
outputLength = n/8
end Select
// try HashText function
dim hash as string = SHA3MBS.HashText(input, rate, capacity, outputLength)
if hash <> output then
break
MsgBox "Error1: "+output
end if
List.AddRow hash
// try Hash function
dim hashb as string = SHA3MBS.Hash(input, rate, capacity, outputLength)
if EncodeHex(hashb) <> output then
break
MsgBox "Error2: "+output
end if
// try class with ResultText function
dim s as new SHA3MBS(rate, capacity)
s.Add input
dim ht as string = s.ResultText(outputLength)
if ht <> output then
break
MsgBox "Error3: "+output
end if
// try class with Result function
s = new SHA3MBS(rate, capacity)
s.Add input
dim hb as string = s.Result(outputLength)
if EncodeHex(hb) <> output then
break
MsgBox "Error4: "+output
end if
End Sub
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
End Project
The items on this page are in the following plugins: MBS Encryption Plugin.