From d2419bc168f4d7acf0b3ed2aa5d414e3047325c9 Mon Sep 17 00:00:00 2001 From: Sheila Mae Tabligan Date: Wed, 6 Nov 2019 15:10:50 +0800 Subject: [PATCH 1/2] Added sample app with gui for AES128 --- src/sling/aes128gui/MainWidget.sling | 58 ++++++++++++++++++++++++++++ src/sling/aes128gui/module.pling | 26 +++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/sling/aes128gui/MainWidget.sling create mode 100644 src/sling/aes128gui/module.pling diff --git a/src/sling/aes128gui/MainWidget.sling b/src/sling/aes128gui/MainWidget.sling new file mode 100644 index 0000000..c5d23d7 --- /dev/null +++ b/src/sling/aes128gui/MainWidget.sling @@ -0,0 +1,58 @@ + +/* + * This file is part of Eqela Samples + * Copyright (c) 2016-2018 Job and Esther Technologies Oy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import capex.crypto + +class #widget #main: + +ui LayerWidget +{ + CanvasWidget { + color = Color.forString("#CCCCCC") + } + VerticalBoxWidget { + margin = context.getHeightValue("10mm") + spacing = context.getHeightValue("10mm") + LabelWidget encryptedText { + text = "Encrypt" + textAlign = LabelWidget.ALIGN_CENTER + } + LabelWidget decryptedText { + text = "Decrypt" + textAlign = LabelWidget.ALIGN_CENTER + } + } +} + +func initializeWidget override +{ + base.initializeWidget() + var encipher = AES128Cipher.create("SampleAES128IVal", "Sample AES128Key") + var encrpyt = BlockCipher.encryptString("Hello World", encipher) + encryptedText.setWidgetText("Encrypted: " .. Base64Encoder.encode(encrpyt)) + var decipher = AES128Cipher.create("SampleAES128IVal", "Sample AES128Key") + var decrypt = BlockCipher.decryptString(encrpyt, decipher) + decryptedText.setWidgetText("Decrypted : " .. decrypt) + PRINT "Decrypt : " .. decrypt +} diff --git a/src/sling/aes128gui/module.pling b/src/sling/aes128gui/module.pling new file mode 100644 index 0000000..2b8bd55 --- /dev/null +++ b/src/sling/aes128gui/module.pling @@ -0,0 +1,26 @@ + +/* + * This file is part of Eqela Samples + * Copyright (c) 2016-2018 Job and Esther Technologies Oy + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +preFilters += "@cape" +preFilters += "@caveui" From 964b4f8149a9a337570b1749faa4a92202728840 Mon Sep 17 00:00:00 2001 From: Sheila Mae Tabligan Date: Fri, 8 Nov 2019 14:49:48 +0800 Subject: [PATCH 2/2] Fixed typo error --- src/sling/aes128gui/MainWidget.sling | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sling/aes128gui/MainWidget.sling b/src/sling/aes128gui/MainWidget.sling index c5d23d7..583e31d 100644 --- a/src/sling/aes128gui/MainWidget.sling +++ b/src/sling/aes128gui/MainWidget.sling @@ -48,11 +48,11 @@ ui LayerWidget func initializeWidget override { base.initializeWidget() - var encipher = AES128Cipher.create("SampleAES128IVal", "Sample AES128Key") - var encrpyt = BlockCipher.encryptString("Hello World", encipher) - encryptedText.setWidgetText("Encrypted: " .. Base64Encoder.encode(encrpyt)) - var decipher = AES128Cipher.create("SampleAES128IVal", "Sample AES128Key") - var decrypt = BlockCipher.decryptString(encrpyt, decipher) + var encipher = AES128Cipher.create("Sample AES128Key", "SampleAES128IVal") + var encrypt = BlockCipher.encryptString("Hello World", encipher) + encryptedText.setWidgetText("Encrypted: " .. Base64Encoder.encode(encrypt)) + var decipher = AES128Cipher.create("Sample AES128Key", "SampleAES128IVal") + var decrypt = BlockCipher.decryptString(encrypt, decipher) decryptedText.setWidgetText("Decrypted : " .. decrypt) PRINT "Decrypt : " .. decrypt }