Program 2: We will create another program with name “ZFILE_DECRYPTION” for decrypting the encrypted file using the generated key.
Sharing the key with intended person via e-mail.
Encrypting the file with the generated key.
Generation of the “KEY” which will be used in encryption process.
Creation of the file which needs to be encrypted.
In this program we will do the following task:.
Program 1: We will create a program with name “ZFILE_ENCRYPTION”.
So, let’s demonstrate the complete process of encryption and decryption using a key in ABAP. These are the algorithms been followed universally, so even if the target system is a non-SAP system, the encrypted file from SAP can be decrypted using the correct key in the target system and vice-versa(and yes, the algorithm used during encryption process should be used during decryption process, of course). The class “CL_SEC_SXML_WRITER” contains 3 algorithm for encryption and decryption. We will be using the class “CL_SEC_SXML_WRITER” for encryption and decryption process. The mechanism mentioned above is called “Symmetric Key Encryption” in Cryptography(as the same key is used in the encryption and decryption process, hence the name “Symmetric”). I thought to share this so that it can be helpful to someone. To avoid the misutilization of any sensitive data by the third party middle-ware, we have encoded the file using a key(key is generated every-time, hence the key is unique always) and the key has been shared with the concerned person of the target system via e-mail. The third party middle-ware reads the file from SAP application server and sends it to the target system. Recently I came across a requirement where we have to encrypt the generated file while placing it in application server( t-code – AL11 ). You can also try this blog post if you are getting run time error “CX_SEC_SXML_ENCRYPT_ERROR” in class “CL_SEC_SXML_WRITER” during decryption of the data. By end of this blog post, we will be able to learn ‘how to encrypt a text file or data using a key and in the end we will also able know “how to decrypt the encrypted data using the same key”.
This blog post is intended to give an overall idea on file encryption and decryption process using a key in ABAP.