B4A Library AES Encrypt/Decrypt (Encryption/Decryption) B4A and B4J library

Discussion in 'Additional libraries, classes and official updates' started by Peter Simpson, Jul 9, 2019.

  1. Peter Simpson

    Peter Simpson Expert Licensed User

    This library works with both B4A and B4J.
    Yes yes yes there are other ways to do this, this is how I do it. I have lots of small libraries that I use for myself, so I thought that I would share this one with the community.

    Hello fellow B4X'ers,
    I've decided to release this simple to use AES library, I created it some time ago for AES Encryption and Decryption of strings. I've been using this library in multiple B4X projects for quite some time now and I've never come across any issues with it. I decided to removed some methods that you don't need, so here it is.

    How to use this library:
    Just download the attached zip file and unzip the 2 files into your additional libraries folder.
    Code:
    Sub Process_Globals
        
    '******************************************************************************
        '* THIS IS AVAILABLE FOR B4A, B4J AND VB.NET UNDER THE SAME FILE NAME AND DLL *
        '******************************************************************************

        
    Private EncDec As AESEncryption
    End Sub

    Sub AppStart (Args() As String)
        EncDec.InitializationVector = 
    "Q.6qYq0_C+mGmymX" 'Must be 16 characters in length
        EncDec.SecretKey = "3hba8fOumOPrMG0.G?-mkF-scGOkPwyW" 'Must be 16 or 32 characters in length

        
    Dim EncryptDecryptString As String = "Peter"
        
    Log($"Encrypted = ${EncDec.AESEncrypt(EncryptDecryptString)}"$)
        
    Log($"Decrypted = ${EncDec.AESDecrypt(EncDec.AESEncrypt(EncryptDecryptString))}"$)
        StartMessageLoop
    End Sub
    Picked up _JAVA_OPTIONS: -Xmx1024m -Xms1024m -XX:-UseGCOverheadLimit
    Waiting for debugger to connect...
    Program started.
    Encrypted = DB35530CCAD0E190E8DAF728DF4D4F8D
    Decrypted = Peter

    Released: 09/07/2019: 1.00

    SS_AESEncryption


    Author: Peter Simpson
    Version: 1
    • AESEncryption
      • Fields:
        • InitializationVector As String
        • SecretKey As String
      • Functions:
        • AESDecrypt (DecryptData As String) As String
          Decrypt AES encoded data to plain string
        • AESEncrypt (EncryptData As String) As String
          Encrypt plain string to AES encoded data
        • Initialize As String
          Use Initialize for B4A, Initialize is NOT necessary for B4J
        • IsInitialized As Boolean
          Tests whether the object has been initialized.

    I use this library to encrypt data into and decrypt data out of my clients MySQL or MSSQL databases. For many years I've been developing bespoke Windows business software for clients using VB.Net, I've always encrypted important data using AES encryption, after all some encryption is better than no encryption.

    Enjoy...
     

    Attached Files:

    Last edited: Jul 10, 2019
  2. DonManfred

    DonManfred Expert Licensed User

    SS = ??

    SuperSimpson?
    SimpsonSpecial?

    Sorry, could´nt resist ;-)
     
  3. Peter Simpson

    Peter Simpson Expert Licensed User

  4. DonManfred

    DonManfred Expert Licensed User

    You didn´t give a proov of this...

    But honestly; i don´t want to see it though! No matter if you would proov the widespread fantasy or not :D:D
     
    Peter Simpson and Johan Hormaza like this.
  5. Peter Simpson

    Peter Simpson Expert Licensed User

    I can't, public forum, sorry :p

    Enjoy the library :)
     
    DonManfred likes this.
  6. DonManfred

    DonManfred Expert Licensed User

    HA HA HA :D:D:D
     
    Peter Simpson likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice