Decryption

Decrypt a file

To decrypt an encrypted file, it is necessary to set the same key used to encrypt the origin file. This requires specifying the key file, the decrypted file and an output directory as absolute paths.

  1. setKey(“C:\\1712213110928004300_a7721cd837e1de1e5c0daec15bf4c13fca340142.key”);
  2. fileDecryption(“C:\\1713029475699363400_g7nnmy6cEHgoOK4YYSIiOBXWhYMDC2Gs.msk”, “C:\\”); // encrypted file, output directory

    In this way, the output directory is specified and thus works fine. If the output directory of fileDecryption(String encryptedFileName, String outputDirectory) method is left empty without set the output directory with the command setDecryptedFilesDirectory(String directory) , an error occurs as follows:
  1. setKey(“C:\\1712213110928004300_a7721cd837e1de1e5c0daec15bf4c13fca340142.key”);
  2. fileDecryption(“C:\\1713029475699363400_g7nnmy6cEHgoOK4YYSIiOBXWhYMDC2Gs.msk”, “”); // encrypted file, output directory
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2024.04.15 05:08:25.154 RUNNING setKeyFilename() ::
2024.04.15 05:08:25.155 SETTING the key
2024.04.15 05:08:25.155 C:\1712943198082683900_0f36d8fe7baa9e26c67ac6be9325f3c8.key 4.194.304-byte
2024.04.15 05:08:25.156 sub-key_1: from index '0' to index '2.097.151'
2024.04.15 05:08:25.156 sub-key_2: from index '2.097.152' to index '4.194.304'
2024.04.15 05:08:25.235
2024.04.15 05:08:25.235 This key adds 9708 random bytes to the top of pre-encryption data if origin data is a file
2024.04.15 05:08:25.235 and 303 random bytes to the top of pre-encryption data if origin data is a byte array
2024.04.15 05:08:25.235
2024.04.15 05:08:25.236 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2024.04.15 05:08:25.236 RUNNING fileDecryption() ::
2024.04.15 05:08:25.236 ERROR: The directory for saving the decrypted files has not been set
2024.04.15 05:08:25.236
2024.04.15 05:08:25.236 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

The decrypted file can also be obtained through the following ways:

  1. #
    • setKeyFilesDirectory(“C:\\Users\\guest\\ema\\key\\”); // default is empty
    • setEncryptedFilesDirectory(“C:\\Users\\guest\\ema\\msk\\”); // default is empty
    • setDecryptedFilesDirectory(“C:\\Users\\guest\\ema\\usk\\”); // default is empty
    • setKey(“1712213110928004300_a7721cd837e1de1e5c0daec15bf4c13fca340142.key”);
    • fileDecryption(“1713029475699363400_g7nnmy6cEHgoOK4YYSIiOBXWhYMDC2Gs.msk”, “”);

      In this way, the directories have been specified by setting the directives setKeyFilesDirectory(absolutePathDirectory), setEncryptedFilesDirectory(absolutePathDirectory) and setDecryptedFilesDirectory(absolutePathDirectory)
  2. #
    • setKey(“C:\\1712213110928004300_a7721cd837e1de1e5c0daec15bf4c13fca340142.key”);
    • enableSaveDecryptedFileToOriginDirectory();
    • fileDecryption(“C:\\1713029475699363400_g7nnmy6cEHgoOK4YYSIiOBXWhYMDC2Gs.msk”, “”); // encrypted file, output directory

      The encrypted file specifies the output directory, ensuring proper functionality. Even if the output directory is specified in fileDecryption(), enableSaveDecryptedFileToOriginDirectory() takes precedence.

After saving the decrypted file back to its original format, a .csv file containing all of the original file’s information is generated in the same directory.

Here is the result:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2024.04.13 17:32:25.165 RUNNING setKeyFilename() ::
2024.04.13 17:32:25.167 SETTING the key
2024.04.13 17:32:25.167 C:\1712943198082683900_0f36d8fe7baa9e26c67ac6be9325f3c8.key 4.194.304-byte
2024.04.13 17:32:25.168 sub-key_1: from index '0' to index '2.097.151'
2024.04.13 17:32:25.168 sub-key_2: from index '2.097.152' to index '4.194.304'
2024.04.13 17:32:25.241
2024.04.13 17:32:25.241 This key adds 9708 random bytes to the top of pre-encryption data if origin data is a file
2024.04.13 17:32:25.242 and 303 random bytes to the top of pre-encryption data if origin data is a byte array
2024.04.13 17:32:25.242
2024.04.13 17:32:25.242 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2024.04.13 17:32:25.242 RUNNING fileDecryption() ::
2024.04.13 17:32:25.244 SETTING 'C:\' as output decrypted files directory
2024.04.13 17:32:25.245 FILE TO DECRYPT
2024.04.13 17:32:25.245 C:\1713029475699363400_g7nnmy6cEHgoOK4YYSIiOBXWhYMDC2Gs.msk 65.536-byte
2024.04.13 17:32:25.245 ..................................................................................................
2024.04.13 17:32:25.245 DECRYPTION KEY
2024.04.13 17:32:25.246 C:\1712943198082683900_0f36d8fe7baa9e26c67ac6be9325f3c8.key 4.194.304-byte
2024.04.13 17:32:25.246 sub-key_1: from index '0' to index '2.097.151'
2024.04.13 17:32:25.246 sub-key_2: from index '2.097.152' to index '4.194.304'
2024.04.13 17:32:25.246
2024.04.13 17:32:25.246 This key adds 9708 random bytes to the top of pre-encryption data if origin data is a file
2024.04.13 17:32:25.247 and 303 random bytes to the top of pre-encryption data if origin data is a byte array
2024.04.13 17:32:25.286
2024.04.13 17:32:25.286 The decryption key is correct
2024.04.13 17:32:25.287 ..................................................................................................
2024.04.13 17:32:25.287 BYTE BLOCK SIZE
2024.04.13 17:32:25.287 Size = 65.536-byte
2024.04.13 17:32:25.287 ..................................................................................................
2024.04.13 17:32:25.287 ENCRYPTION WAS PERFORMED
2024.04.13 17:32:25.288 ..................................................................................................
2024.04.13 17:32:25.288 CHECKSUM FOUND
2024.04.13 17:32:25.288 Algorithm: MD5
2024.04.13 17:32:25.288 ..................................................................................................
2024.04.13 17:32:25.289 DECRYPTION SETTINGS
2024.04.13 17:32:25.289 Decryption details: ENABLED
2024.04.13 17:32:25.289 Save the decrypted file to origin directory: DISABLED
2024.04.13 17:32:25.289 ..................................................................................................
2024.04.13 17:32:25.289 STARTING THE CORE EXECUTION IN DECRYPTION MODE
2024.04.13 17:32:25.290 Reading the encrypted byte block 0000000001 00000118µs 65.536-byte
2024.04.13 17:32:25.291 Decrypting the byte block 0000000001 00000813µs
2024.04.13 17:32:25.292 Calculating MD5 checksum 00000291µs
2024.04.13 17:32:25.293 Writing the decrypted byte block 0000000001 00000179µs 635-byte
2024.04.13 17:32:25.293 FINISHED THE CORE EXECUTION IN DECRYPTION MODE
2024.04.13 17:32:25.293 ..................................................................................................
2024.04.13 17:32:25.293 OVERALL TIMES
2024.04.13 17:32:25.295 Time to read 0000000001 byte blocks 00000000ms
2024.04.13 17:32:25.295 Time to complete the decryption 00000005ms
2024.04.13 17:32:25.295 Time to calculate the MD5 checksum 00000000ms
2024.04.13 17:32:25.295 Time to write 0000000001 byte blocks 00000000ms
2024.04.13 17:32:25.296 Total time 00000005ms
2024.04.13 17:32:25.296 ..................................................................................................
2024.04.13 17:32:25.296 INFORMATION ABOUT THE ORIGIN (DECRYPTED) FILE
2024.04.13 17:32:25.296
2024.04.13 17:32:25.296 Directory C:\Users\guest\ema\src
2024.04.13 17:32:25.297 Filename Dracula.txt
2024.04.13 17:32:25.297 Size 635-byte
2024.04.13 17:32:25.298 Filesystem type NTFS
2024.04.13 17:32:25.298 Filesystem name Windows
2024.04.13 17:32:25.298 Date of encryption 2024.04.13 19:31:15
2024.04.13 17:32:25.299 Last modified date 2022.09.14 09:13:40
2024.04.13 17:32:25.299 Creation date 2024.03.01 16:41:20
2024.04.13 17:32:25.299 Last access date 2024.03.01 16:41:20
2024.04.13 17:32:25.299 Owner BUILTIN\Administrators (Alias)
2024.04.13 17:32:25.299 Group
2024.04.13 17:32:25.300 Permissions NT AUTHORITY\SYSTEM:READ_DATA/WRITE_DATA/APPEND_DATA/READ_NAMED_ATTRS
2024.04.13 17:32:25.300 /WRITE_NAMED_ATTRS/EXECUTE/DELETE_CHILD/READ_ATTRIBUTES/WRITE_ATTRIBU
2024.04.13 17:32:25.300 TES/DELETE/READ_ACL/WRITE_ACL/WRITE_OWNER/SYNCHRONIZE:ALLOW, BUILTIN\
2024.04.13 17:32:25.300 Administrators:READ_DATA/WRITE_DATA/APPEND_DATA/READ_NAMED_ATTRS/WRIT
2024.04.13 17:32:25.300 E_NAMED_ATTRS/EXECUTE/DELETE_CHILD/READ_ATTRIBUTES/WRITE_ATTRIBUTES/D
2024.04.13 17:32:25.300 ELETE/READ_ACL/WRITE_ACL/WRITE_OWNER/SYNCHRONIZE:ALLOW, BUILTIN\Users
2024.04.13 17:32:25.301 :READ_DATA/READ_NAMED_ATTRS/EXECUTE/READ_ATTRIBUTES/READ_ACL/SYNCHRON
2024.04.13 17:32:25.301 IZE:ALLOW, \Everyone:READ_DATA/READ_NAMED_ATTRS/EXECUTE/READ_ATTRIBUT
2024.04.13 17:32:25.301 ES/READ_ACL/SYNCHRONIZE:ALLOW
2024.04.13 17:32:25.301 ..................................................................................................
2024.04.13 17:32:25.301 SAVING THE ORIGIN (DECRYPTED) FILE AND ITS ORIGIN INFORMATION
2024.04.13 17:32:25.301 C:\Dracula.txt 635-byte
2024.04.13 17:32:25.304 C:\Dracula.txt.csv 975-byte
2024.04.13 17:32:25.304 ..................................................................................................
2024.04.13 17:32:25.304 CHECKSUM MD5 was verified and is correct
2024.04.13 17:32:25.304 Decryption performed successfully
2024.04.13 17:32:25.304
2024.04.13 17:32:25.304 FINISHED fileDecryption() ::
2024.04.13 17:32:25.305
2024.04.13 17:32:25.305 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Decrypt a byte array

As previously stated, the EMA program does not store encrypted byte arrays. Therefore, it is the user’s responsibility to manage them. In the Encrypt a byte array section, we learned how to encrypt a byte array.

To decrypt a byte array you need obviously the same key used to encrytpt and the encrypted byte array as follows:

  • setKey(“C:\\1712213110928004300_a7721cd837e1de1e5c0daec15bf4c13fca340142.key”);

As with encrypting a byte array, decrypting a byte array returns a ByteResult object consisting of a boolean success or failure result and the encrypted byte array as follows:

  • ByteResult decryption = byteArrayDecryption(encryption.getData());

the decryption result is:

  • boolean result = decryption.getResult(); // true -> success, false -> failure

and the decrypted byte array is:

  • byte[] decryptedByteArray = decryption.getData(); // the origin byte array if result is true, otherwise is null

Now the decrypted data must be managed by the user.

Scroll to Top