Design and Implementation of AES and SHA-256
  Cryptography for Securing Multimedia File over
             Android Chat Application
       Noveline Aziz Fauziah                           Eko Hari Rachmawanto                      De Rosal Ignatius Moses Setiadi
Department of Informatics Engineering            Department of Informatics Engineering         Department of Informatics Engineering
    Dian Nuswantoro University                       Dian Nuswantoro University                    Dian Nuswantoro University
        Semarang, Indonesia                             Semarang, Indonesia                           Semarang, Indonesia
   Email: novelineaf@gmail.com                     Email: eko.hari@dsn.dinus.ac.id                Email: moses@dsn.dinus.ac.id
                                                          Christy Atika Sari
                                                 Department of Informatics Engineering
                                                     Dian Nuswantoro University
                                                         Semarang, Indonesia
                                                   Email: atika.sari@dsn.dinus.ac.id
    Abstract— In the current era of globalization, security is        the most widely used utilities where the application allows
one of the most important aspects in the development of               Android users to keep communicating via the internet, both
communication applications, especially when sending                   for sending and receiving messages, photos and videos. One
confidential files. Advanced Encryption Standard (AES) is one         of the many instant message applications used is WhatsApp.
method that can be used to secure data by encrypting and              WhatsApp has facilities that allow users to transfer various
decrypting an information. AES is also an algorithm that has a        media files, such as images, audio and video [9]. There are
fast encryption process and has been widely implemented in            about 1.7 billion WhatsApp application accounts for Android
various fields. To provide data security that is transferred to       users [10]. Besides messaging apps like WhatsApp have
the network, AES is considered a fast and best algorithm. AES
                                                                      implemented end-to-end encryption that makes data
is an open source cryptography with symmetric keys used for
                                                                      transmission safer.
encryption and decryption of files. Files to be encrypted are
multimedia files such as images, audio and video. The file is             Whatsapp also has facilities to be accessed via computer
entered into the application, then the user inputs a key that is      devices via the web.whatsapp.com URL. WhatsApp is one of
encrypted with the SHA-256 algorithm to secure the contents           the largest platforms in the world for online communication
of the file. Encrypted files are stored in the UUencoding format      that is able to send data and information both between
to avoid the compression process when sending files via the           individuals and groups [11]. The process of sending files on
chat application. The file is also safer, because the message
                                                                      WhatsApp is very efficient because the transmitted file will
cannot be seen directly. Based on the results of experiments in
                                                                      be compressed where the file is compressed so that it only
this study, multimedia file encryption applications have been
successfully built. Although the process of encryption and
                                                                      requires smaller storage space and shortens the data
decryption changes the size of the original file a little, the        exchange time. But this method makes users unable to use
contents and meaning of the file remain the same and has been         WhatsApp when they want to send files with original quality.
wrapped up by measuring the PNSR value that produces an               A broad user base also makes this application vulnerable to
infinity value.                                                       hacker attacks and a number of other security risks. In the
                                                                      study [12] an experiment was carried out by retrieving
  Keywords—AES, Cryptography,           Secure     Transmission,      information from two phones that had the WhatsApp
WhatsApp, UUencoding                                                  application installed, and testing them using the IP protocol
                                                                      found some information, such as messages sent, call logs,
                     I. INTRODUCTION                                  timestamps, and so on. Therefore in this study data and
    Today more and more human activities need an internet             information that will be sent in the form of encrypted data
connection. The internet makes it easy for humans to access           that is packaged in a .enc format so that the data can be
data and information. As time goes by, storage of large data          received safely and intact. .Enc file format is a uuencoded
and information is needed. Therefore a security system is             file extension that represents encrypted data using
needed to maintain data integrity [1] [2] [3]. This raises the        UUencoding technology. UUencoding is a binary-to-text
demand for a better data security system to secure data from          coding method with UUencode-based ASCII on UNIX. Files
various threats that may arise [4] [5]. So research on data           that are encoded in this way are generally safe for
security systems and their implementation continues to be             transmission over the internet network and uuencode is also
developed to protect the transmitted data through a                   often used to send binary files via email [13].
communication network [6] [7].                                            Using Uuencode, files can be customized by applying
    The rapid development of mobile internet and                      certain encryption algorithms to improve security. AES
smartphone technology makes it a daily human need. The                cryptography algorithm is a bit-oriented cipher, making it
use of smartphones with the Android operating system (OS)             possible to be implemented efficiently into the software [14].
reaches around 87% of mobile markets worldwide [8].                   Some of the other advantages that AES possesses are
Instant messaging application on the Android OS is one of             resistance to various types of attacks, having a simple design
        !"#$$%!&'(((                    146
                                                            and speed on various platforms [4] [15] [16]. So in this study               data to a different form that called ciphertext. That the
AES algorithm is implemented to encrypt the sending of                       process to inverse ciphertext to original data (plaintext) is
multimedia files such as images, audio or video in an                        decryption. There are three kinds of size of AES keys 128,
Android application where the encryption results will be                     192, and 256 bits. Where, the size of the block data and the
transmitted through the WhatsApp application.                                key will determine the number of processes that must be
                                                                             passed for the encryption and decryption process. Encryption
                      II. RESEARCH METHOD                                    process in AES algorithm consists of four kinds of bytes
A. Interface Design                                                          transformation, namely SubBytes, ShiftRows, Mixcolumns,
                                                                             and AddRoundKey [16]. Where the encryption process in
    Interface design is the most important part of the                       AES algoritm can be seen clearly in Figure 1 [17].
application because when the application is run the first one
is the application interface. Interface design consists of the
main menu and about the app. Interface design using
Android Studio tools and Java language. The main menu
consists of an input file sub-menu, input key or generate a
key, encrypt, and decrypt.
B. CryptoHelper Class Design
    This class is a class that is used to process the encryption
and decryption of files. In the program creation process,
Android Studio software is used using the Java language.
The table below shows the application modules along with
the information that has been made. The display on the
application in the Android OS is set by the XML file
contained in the res folder and layout. Table I is a module
that has functions in each class. Where the class is
interconnected to be able to access the file to be encrypted or
decrypted, and the process of sending files to the chat
application. Table II shows the layout used in the application.
    TABLE I.          PROGRAM MODULES OF FILE ENCRYPTION AND                 Fig. 1. AES Encryption Algorithm
                       DECRYPTION APPLICATIONS
        Module Name                           Description                    D. Secure Hash Algorithm (SHA-256)
 AboutActivity.Java
                                An activity that displays the about              The hash algorithm is one-way encryption where it is
                                menu                                         impossible to find the original message from the generated
                                To accommodate variables and                 message digest. One hash algorithm is SHA-256. SHA-256
 FileProcessor.Java             functions to load files on cellphone         was designed by The National Institute of Standars and
                                memory                                       Technology (NIST) in 2002. SHA-256 receives data input
                                An activity that displays a menu on          with a maximum length of 264 bits and produces output in
 MainActivity.Java
                                the main page                                the form of message digest or hash value with a length of
                                Activity input the file key that will be     256 bits. SHA-256 uses several logic functions including
 PasswordEncryptionTab.Java
                                encrypted                                    AND, OR, XOR, SHIFT (right), and ROTATE (right)
 RandomEncryptionTab.Java       Generate keys for file encryption            operations [18].
                                Set the file input menu and select files        SHA-256 operates on MD4, MD5, and SHA-1
 CacheFileHelper.Java
                                on the cellphone memory                      algorithms. The message will be hashed, first given the
                                Encryption and decryption functions          supporting bits so that the bits have a total length of 512 bits,
 CryptoHelper.Java                                                           then the bits are broken down into bits where each block
                                based on the AES algorithm
                                Processing files to be encrypted using       consists of 512 bits. The blocks are notated as follows M (1),
 PasswordFileEncryptor.Java                                                  M (2), ..., M (N). These bit blocks are processed at one time.
                                a key
                                Processing the file to be decrypted          E. Encryption and Sending File Method
 PasswordFileDecryptor.Java
                                using the key
                                                                                 At this stage the process of designing a multimedia file
       TABLE II.        NAME OF FILE LAYOUT AND ITS FUNCTION
                                                                             encryption system is implemented which implements the
                                                                             AES cryptographic algorithm for use in the application. In
        Module Name                           Description                    applications that are built the encryption process is a system
 activity_about.xml             Set the display on the about page            process that encrypts files, beginning with the selection of
                                                                             multimedia files such as images, audio or video as plaintext
 activity_main.xml              Set the display on the main page             data. If the data has been read by the system, the system will
 password_encryption_tab.xml    Set the password input display               convert the key and plaintext into a bit array and then
                                                                             forward it to the encryption process. In the file encryption
 random_encryption_tab.xml      Set the random password display              process, it uses the AES algorithm to generate the SHA-256
                                                                             key security. Then the results are in the form of a cipher text
C. Advanced Encryption Standard (AES)                                        with the format .enc can be sent to the chat application like
   AES is a symmetric cryptographic algorithm that can be                    WhatsApp more secure. Figure 1 shows the encryption and
used to decoding data. Encryption is processed to change                     sending file method.
                                                                           147
                                                          
                                                                          Based on Figure 3 the process is a description of the file
                                                                      decryption process. Starting with the process of retrieving the
                                                                      data cipher file as cipher text, if the file has been read by the
                                                                      system then it is forwarded to the decryption process which
                                                                      results in the chat application being used. The decryption
                                                                      process certainly uses the same algorithm and key. The input
                                                                      file used is a file with the format .enc which will be
                                                                      decrypted to the original format of the multimedia file.
                                                                                      III. RESUTLS AND DISSCUSSION
                                                                          In this study the application built for the Android
                                                                      operating system with minimum specification specifications
                                                                      is on Android 2.2. The application is built using Android
                                                                      Studio 3.1.4. In an attempt to use a smartphone with Android
                                                                      Oreo version 8.1. Figure 4 shows the appearance of the
                                                                      Android application that was designed and implemented in
                                                                      this study.
Fig. 2. Encryption and Sending File Method
F. Decryption Method
                                                                      Fig. 4. Application Interface
                                                                          In the main menu display there are parts of the core
                                                                      application that has been created. The functions of these
                                                                      parts include:
                                                                          1.   Input File: is a button that is used to enter the file to
                                                                               be encrypted. Users can import files from Google
                                                                               Drive, Android SD Card or from the gallery.
                                                                          2. Enter Key: used to enter a key when the user wants
                                                                               to encrypt or decrypt files.
                                                                          3. Encrypt: used to process the encryption command
                                                                               that has been given so that it is executed so that the
                                                                               file cannot be read.
                                                                          4. Decrypt: used to restore files in their original form so
                                                                               that the file can be read again.
                                                                          5. Generate Key: used if the user wants to encrypt files
                                                                               using keys randomly. This aims to increase the
                                                                               secure value of the file.
                                                                          Application testing is done with audio, video and image
                                                                      files from the default of Windows 7 OS. Where each file has
                                                                      the format (.wmv) for video, (.jpg) for the image, and (.mp3)
                                                                      for audio. Where each file used can be seen in Figure 5.
Fig. 3. Decryption Method
                                                                148
                                                                
               (a)                                   (b)
               (c)                                   (d)
Fig. 5. Multimedia files used in the experiment {(a) Audio files, (b) Video
      files, (c) Tulips.jpg, (d) Chrysanthemum.jpg}
    Then each file is encrypted with the resulting method so                  Fig. 8. Sample Encryption results of the image file (Tulips.mp3)
that the encryption data is obtained as shown in Figure 6 to
Figure 8.
Fig. 6. Encryption results of video file (Wildlife.wmv)
                                                                              Fig. 9. Display of sending encrypted files via WhatsApp
                                                                                  From the example file shown in Figure 6 to Figure 8,
                                                                              shows that after the encryption process, the contents of the
                                                                              file in the image, audio and video cannot be opened with the
                                                                              default Android OS application and all files change the
                                                                              format to .enc file, this indicates that the file has been
                                                                              protected and ready to be sent. Examples show sending files
                                                                              via the WhatsApp Chat application aimed at Figure 9.
                                                                                  To be read again, the file needs to be decrypted. In the
                                                                              decryption process is done on the receiving side of the file,
                                                                              also must use the same application. Then the recipient of the
                                                                              file, inputting the encrypted file format .enc and the key
                                                                              during the encryption process. So that the file can be
                                                                              decrypted and read again by the Android OS. The test results
                                                                              for files that have been encrypted, sent and decrypted are
Fig. 7. Sample Encryption results of an audio file (Kalimba.mp3)
                                                                              presented in Table III, Table IV and Table V.
                                                                          149
                                                                  
   TABLE III.        ENCRYPTED AND DECRYPTED FILE SIZE IN BYTES              confidential multimedia files will be more protected. It's just
                        Original File      Encrypted        Decrypted        that the encryption and decryption process produces negative
     File Name
                            Size            File Size        File Size       side effects that can increase file size, even though the
 Kalimba.mp3            8415232           9898557          9437184           increase is not significant. Even though the file size is fruitful
                                                                             but the contents of the file have not changed and have been
 Sleep Away.mp3         4843520           5494538          5242880           tested using the PSNR function in Matlab. The PSNR value
 Tulips.jpg             621568            1075200          1048576           obtained is infinity, this proves that the original file contents
                                                                             are exactly the same as the decrypted files. Changes in file
 Chrysantemum.jpg       879616            1075200          1048576           size may be due to changes in the value in the header file due
 Wildlife.wmv           26246144          27674624         27262976          to the encryption and decryption process.
    Based on Table III it appears that there is a difference in                                             REFERENCES
file size. Where this file changes in size, both encrypted files
                                                                             [1]    R. D. Ardy, O. R. Indriani, C. A. Sari, D. R. I. M. Setiadi and E. H.
and decrypted files. This happens because the blocking                              Rachmawanto, "Digital image signature using triple protection
length in the header cipher text file is caused by both the                         cryptosystem (RSA, Vigenere, and MD5)," in International
encryption process and the use of the extension .enc.                               Conference on Smart Cities, Automation & Intelligent Computing
However, the decrypted file does not change the value and                           Systems (ICON-SONICS), Salatiga, 2017.
meaning of the file contents. This is evidenced by the PSNR                  [2]    U. Sudibyo, F. Eranisa, E. H. Rachmawanto, D. R. I. M. Setiadi and
value that produces an infinity value. The PSNR value is                            C. A. Sari, "A secure image watermarking using Chinese remainder
                                                                                    theorem based on haar wavelet transform," in International
generated from the comparison of the original file and the                          Conference on Information Technology, Computer, and Electrical
decrypted file [19]. The infinity value indicates that the                          Engineering (ICITACEE), Semarang, 2017.
contents of the original file are the same as the contents of                [3]    E. J. Kusuma, C. A. Sari, E. H. Rachmawanto and D. R. I. M. Setiadi,
the decrypted file [20]. The PSNR calculation process is                            "A Combination of Inverted LSB, RSA, and Arnold Transformation
performed with the PSNR function contained in Matlab. The                           to get Secure and Imperceptible Image Steganography," Journal of
measurement results of PSNR values are shown in table IV.                           ICT Research and Applications, vol. 12, no. 2, pp. 103-122, 2018.
                                                                             [4]    A. Vichare, J. Tiwari and . U. Yadav, "Data Security using
    TABLE IV.       PSNR RESULTS FROM THE COMPARISON OF THE                         Authenticated Encryption and Decryption Algorithm for Android
                  ORIGINAL FILE AND DECRYPTED FILE                                  Phones," in International Conference on Computing, Communication
                                                                                    and Automation (ICCCA), Greater Noida, 2017.
                       File Name           PSNR (dB)                         [5]    E. J. Kusuma, O. R. Indriani, C. A. Sari, E. H. Rachmawanto and D.
                                                                                    R. I. M. Setiadi, "An Imperceptible LSB image Hiding on Edge
                  Kalimba.mp3             inf
                                                                                    Region using DES Encryption," in International Conference on
                  Sleep Away.mp3          inf                                       Innovative and Creative Information Technology (ICITech), Salatiga,
                                                                                    2017.
                  Tulips.jpg              inf                                [6]    G. Ardiansyah, C. A. Sari, D. R. I. M. Setiadi and E. H.
                                                                                    Rachmawanto, "Hybrid Method using 3-DES, DWT and LSB for
                  Chrysantemum.jpg        inf                                       Secure Image Steganography Algorithm," in International
                  Wildlife.wmv            inf                                       conferences on Information Technology, Information Systems and
                                                                                    Electrical Engineering (ICITISEE), Yogyakarta, 2017 .
                                                                             [7]    D. R. I. M. Setiadi, H. A. Santoso, E. H. Rachmawanto and C. A.
     TABLE V.         ENCRYPTED AND DERYPTED TIME IN SECONDS                        Sari, "An improved message capacity and security using divide and
                                                                                    modulus function in spatial domain steganography," in International
                                    Encrypted        Decrypted
              File Name                                                             Conference on Information and Communications Technology
                                      Time             Time
                                                                                    (ICOIACT), Yogyakarta, 2018.
        Kalimba.mp3                7.3              9.1                      [8]    K. Rathi, U. Karabiyik, T. Aderibigbe and H. Chi, "Forensic Analysis
                                                                                    of Encrypted Instant Messaging Applications on Android," in
        Sleep Away.mp3             5.4              6.4
                                                                                    International Symposium on Digital Forensic and Security (ISDFS),
        Tulips.jpg                 2.6              2.9                             Antalya, 2018.
                                                                             [9]    P. E. Hertzog and A. J. Swart, "The use of WhatsApp in design-based
        Chrysantemum.jpg           2,3              2.7                             modules," in IEEE Global Engineering Education Conference
                                                                                    (EDUCON), Tenerife, 2018.
        Wildlife.wmv               21.0             23.9
                                                                             [10]   A. Shortall and M. A. H. Bin Azhar, "Forensic acquisitions of
    Table IV shows the results of calculations with PSNR                            WhatsApp data on popular mobile platforms," in International
generating inf values, this means that the contents of the file                     Conference on Emerging Security Technologies (EST),
are exactly the same as the original file, even though the file                     Braunschweig, 2015.
size changes. Changes may occur only in metadata and have                    [11]   K. F. Mefolere, "WhatsApp and Information Sharing: Prospect and
                                                                                    Challenges," International Journal of Social Science and Humanities
no effect on the contents of the file.                                              Research , vol. 4, no. 1, pp. 615-625, 2016.
    In Table V also presented the results of measuring the                   [12]   F.Karpisek, I. Baggili and F.Breitinger, "WhatsApp network
time of the encryption and decryption process. It can be seen                       forensics: Decrypting and understanding the WhatsApp call signaling
                                                                                    messages," Digital Investigation, vol. 15, pp. 110-118, 2015.
that the decryption process takes longer than the encryption
                                                                             [13]   IBM Knowledge Center, "uuencode() function," IBM, 15 August
process. This is directly proportional to the size of the                           2015.                         [Online].                     Available:
enlarged file.                                                                      https://www.ibm.com/support/knowledgecenter/en/SSULQD_7.2.1/c
                                                                                    om.ibm.nz.sqltk.doc/r_sqlext_uuencode.html.         [Accessed      26
                          IV. CONCLUSION                                            September 2018].
    Based on the testing and analysis conducted in this study,               [14]   S. Tayde and S. Siledar, "File Encryption, Decryption Using AES
it can be concluded that the application made in this study                         Algorithm in Android Phone," International Journal of Advanced
                                                                                    Research in Computer Science and Software Engineering, vol. 5, no.
successfully implemented the AES algorithm with the SHA-                            5, pp. 550-554, 2015.
256 key to encrypt and decrypt multimedia files such as
images, audio and video. That way, of course, sending
                                                                         150
                                                               
[15] B. Rao, D. Tejaswi, K. Varshini, K. P. Shankar and B. Prasanth,         [18] R. P. Naik, "Optimising the SHA256 Hashing Algorithm for Faster
     "Design Of Modified AES Algorithm For Data Security,"                        and More Efficient Bitcoin Mining," Department cf Computer
     International Journal For Technological Research In Engineering, vol.        Science University College London, London , 2013.
     4, no. 8, pp. 1289-1292, 2017.                                          [19] M. N. M. Najih, D. R. I. M. Setiadi, E. H. Rachmawanto, C. A. Sari
[16] E. H. Rachmawanto, R. S. Amin, D. R. I. M. Setiadi and C. A. Sari,           and S. Astuti, "An improved secure image hiding technique using PN-
     "A performance analysis StegoCrypt algorithm based on LSB-AES                sequence based on DCT-OTP," in International Conference on
     128 bit in various image size," in International Seminar on                  Informatics and Computational Sciences (ICICoS), Semarang, 2017.
     Application for Technology of Information and Communication             [20] D. R. I. M. Setiadi and J. Jumanto, "An Enhanced LSB-Image
     (iSemantic), Semarang, 2017.                                                 Steganography Using the Hybrid Canny-Sobel Edge Detection,"
[17] F. Shao, Y. Zhang and Z. Chang, "AES Encryption Algorithm Based              Cybernetics and Information Technologies, vol. 18, no. 2, pp. 74-88,
     on the High Performance Computing of GPU," in Second                         2018.
     International Conference on Communication Software and Networks,
     Nanjing, China, 2010.
                                                                         151