One-way hash encrypting/decrypting
By Imre Kabai
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
This tip is published with the permission of Imre Kabai.
This program encrypts and decrypts a string using an 8 byte strong one-way-hash like encrypting method. Instead of bit operation, it uses byte operations, because of ABAP's lack of bit operations.
It is useful to process sensitive data (HR ...), that would be otherwise accessible by both ABAPs and UNIX users (root, adm).
The algorithm of the encrypting:
result(1) = source(1) @ initial_key
result(n) = source(n) @ source(n-1) @ result(n-1)
The algorithm of the decrypting:
source(1) = result(1) # initial_key
source(n) = result(n) # result(n-1) # source(n-1)
Where source, result, initial_key are 8 byte strings, @ and # are negate byte operations of each other
REPORT ZENCRYPT. PARAMETERS: STRING(96), KEY(8). PARAMETER ENCRYPT RADIOBUTTON GROUP RB. PARAMETER DECRYPT RADIOBUTTON GROUP RB. DATA: I TYPE I, J TYPE I. DATA: BEGIN OF A, 1 TYPE X, 2 TYPE X, 3 TYPE X, 4 TYPE X, 5 TYPE X, 6 TYPE X, 7 TYPE X, 8 TYPE X, END OF A. DATA: BEGIN OF B, 1 TYPE X, 2 TYPE X, 3 TYPE X, 4 TYPE X, 5 TYPE X, 6 TYPE X, 7 TYPE X, 8 TYPE X, END OF B. DATA: BEGIN OF C, 1 TYPE X, 2 TYPE X, 3 TYPE X, 4 TYPE X, 5 TYPE X, 6 TYPE X, 7 TYPE X, 8 TYPE X, END OF C. DATA: BEGIN OF D, 1 TYPE X, 2 TYPE X, 3 TYPE X, 4 TYPE X, 5 TYPE X, 6 TYPE X, 7 TYPE X, 8 TYPE X, END OF D. DATA: BEGIN OF E, 1 TYPE X, 2 TYPE X, 3 TYPE X, 4 TYPE X, 5 TYPE X, 6 TYPE X, 7 TYPE X, 8 TYPE X, END OF E. WRITE: / STRING. * encrypting J = STRLEN( STRING ). A = KEY. DO. B = STRING+I. E = B. IF SY-INDEX = 1. B-1 = A-1 + B-1.B-2 = A-2 + B-2.B-3 = A-3 + B-3.B-4 = A-4 + B-4. B-5 = A-5 + B-5.B-6 = A-6 + B-6.B-7 = A-7 + B-7.B-8 = A-8 + B-8. ELSE. B-1 = C-1 + D-1 + B-1.B-2 = C-2 + D-2 + B-2. B-3 = C-3 + D-3 + B-3.B-4 = C-4 + D-4 + B-4. B-5 = C-5 + D-5 + B-5.B-6 = C-6 + D-6 + B-6. B-7 = C-7 + D-7 + B-7.B-8 = C-8 + D-8 + B-8. ENDIF. D = B. C = E. STRING+I(8) = B. I = I + 8. IF I >= J. EXIT. ENDIF. ENDDO. WRITE: / STRING. * decrypting J = STRLEN( STRING ). I = 0. A = KEY. DO. B = STRING+I. E = B. IF SY-INDEX = 1. B-1 = B-1 - A-1.B-2 = B-2 - A-2.B-3 = B-3 - A-3.B-4 = B-4 - A-4. B-5 = B-5 - A-5.B-6 = B-6 - A-6.B-7 = B-7 - A-7.B-8 = B-8 - A-8. ELSE. B-1 = B-1 - C-1 - D-1.B-2 = B-2 - C-2 - D-2. B-3 = B-3 - C-3 - D-3.B-4 = B-4 - C-4 - D-4. B-5 = B-5 - C-5 - D-5.B-6 = B-6 - C-6 - D-6. B-7 = B-7 - C-7 - D-7.B-8 = B-8 - C-8 - D-8. ENDIF. D = B. C = E. STRING+I(8) = B. I = I + 8. IF I >= J. EXIT. ENDIF. ENDDO. WRITE: / STRING.
Did you like this tip? Hate it? Write to us at tips@searchSAP.com to let us know your thoughts.
SAP R3 Reporting Tools
Author : Danielle Larocca
Publisher : McGraw-Hill
ISBN/CODE : 0072123427
Cover Type : Soft Cover
Pages : 400
Published : Dec 1999
One of the key reasons to implement the SAP R/3 system in any organization is the ability to integrate information from every division of your company, and then generate reports that display the data in a useful format. But, whether you're an SAP user, developer, or consultant, you know that there is limited information available that shows how to locate and execute standard reports in SAP as well as how to retrieve data and create your own standard SAP reports. This user-friendly, practical guide will walk you through the process of creating, customizing, and producing reports quickly and easily.