Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Decrypt and Encrypt a CHAR Field

martin_stampfl3
Explorer
0 Likes
2,393

Hello everybody,

my issue is that I want to encrypt a Char field with length 12, which is written in a table. It should be possible if necessary to decrypt the char field after encryption. Do you have any suggestions?

Thank you already

Best Regards

Martin

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,352

There is a good blog related to this topic [Encryption & Decryption of data using ABAP|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5026]. The class cl_hard_wired_encryptor is used for this.

6 REPLIES 6
Read only

Former Member
0 Likes
1,352

When we had a similar requirement for encrypting salary field what we did was creating a key table(db) with structure

ZCHAR type char.

ZKEY TYPE char(5).

The entries were on lines of

1 @#$fd

2 ^%#NF

....and so on.

Then when we encrypted by reading each and every char and translating to key and appending to string...

EX: 21 -> ^%#NF@#$fd.

and similarly for decrypting. This allowed us to change keys monthly to prevent anyone from being smart and guessing at the salaries too...

Read only

andrs_sarcevic
Contributor
0 Likes
1,352

Have a look [here|http://www.sap-img.com/abap/function-module-for-encryption-and-decryption.htm].

What Ncvajja suggested is a valid approach but... the method used is easily guessed by accessing that table (SAP security should be involved).

Do a search for the common encryption algorithms. They shouldn't be hard to implement in ABAP.

Regards,

Andres.

Read only

Former Member
0 Likes
1,352

Hi Martin..

try this code


Data enpwd(32) type c.
parameter pwd like enpwd .

******** Encrypting *******************
CALL FUNCTION 'FIEB_PASSWORD_ENCRYPT'
EXPORTING
IM_DECRYPTED_PASSWORD = pwd
IMPORTING
EX_ENCRYPTED_PASSWORD = enpwd
.
******** Decrypting *******************
CALL FUNCTION 'FIEB_PASSWORD_DECRYPT'
EXPORTING
IM_ENCRYPTED_PASSWORD = enpwd
IMPORTING
EX_DECRYPTED_PASSWORD = pwd
.

********* Output **********************
write:/ 'Encrypt data=', enpwd,
/ 'Decrypt data=', pwd. 

also try this forum links

http://forums.sdn.sap.com/thread.jspa?messageID=5077062#5077062

https://forums.sdn.sap.com/thread.jspa?threadID=1196646&tstart=0

Regards .

Shiva

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,353

There is a good blog related to this topic [Encryption & Decryption of data using ABAP|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5026]. The class cl_hard_wired_encryptor is used for this.

Read only

0 Likes
1,352

Thanks a lot Keshav, this blog helped me to solve my problem

Read only

0 Likes
1,352

Martin, keep in mind that blog does not describe a powerful encryption method like [AES|http://en.wikipedia.org/wiki/Advanced_Encryption_Standard] or [Blowfish|http://en.wikipedia.org/wiki/Blowfish_(cipher)], but common [BASE64 Encoding|http://en.wikipedia.org/wiki/Base64]. Take a look at the comments on the blog.

Regards,

Andres.