‎2013 Oct 16 8:20 AM
I'm trying to conduct hash check on payment file to see if anyone has changed the payment file manually before signing it with a digital signature.
However when I download the payment file from the server some whitespaces go missing on the way to the client's computer. The problem is that a file that hasn't been modified in any way produces a different hash after signing. So I was thinking what if i removed all whitespaces (space, linefeed, carriage return, nbsp) from the file then maybe it finally calculates correct hash for both files. However I can't find any functionality that lets me remove all whitespace characters from the string. Alpha Conversion removes spaces from the end of the string but since I need to also remove spaces and line breaks from inside the string this isn't really an option. I would greatly appreciate if someone provided me with some information how to achieve this.
‎2013 Oct 16 11:44 AM
These are all good suggestions but afterall I went with something I made myself especially because I can be sure that this way all the unnecessary characters are removed and necessary characters remain:
len = strlen( initial_file ).
DO len TIMES.
SUBTRACT 1 FROM len.
IF 'ABCDEFGHIJKLMNOPQRSŠZŽTUVÕÄÖÜXY1234567890.,"<>?=-:/' CS initial_file+len(1).
CONCATENATE initial_file+len(1) temp into temp.
ENDIF.
ENDDO.
‎2013 Oct 16 8:30 AM
Hi,
data: teststring type string .
replace all occurrences of cl_abap_char_utilities=>CR_LF in teststring with '' .
replace all occurrences of cl_abap_char_utilities=>NEWLINE in teststring with '' .
condense teststring.
For more options you can explore class CL_ABAP_CHAR_UTILITIES
regards,
Ashish Rawat
‎2013 Oct 16 8:32 AM
Hello Rauno,
Try with REPLACE ALL OCCURRENCES OF pattern IN variable WITH ''.
I hope that I understood well your question.
‎2013 Oct 16 8:40 AM
Hello Rauno,
since I need to also remove spaces and line breaks from inside the string this isn't really an option.
I think you can use the RegEx [[:space:]] to remove the "white-space characters" from your string.
BR,
Suhas
PS - You can play around with your RegEx in DEMO_REGEX_TOY & build the one which suits your requirement
‎2013 Oct 16 9:37 AM
Hi ,
Please try like this,
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>newline in
variable_name WITH ''.
Thanks,
Vijay.
‎2013 Oct 16 11:44 AM
These are all good suggestions but afterall I went with something I made myself especially because I can be sure that this way all the unnecessary characters are removed and necessary characters remain:
len = strlen( initial_file ).
DO len TIMES.
SUBTRACT 1 FROM len.
IF 'ABCDEFGHIJKLMNOPQRSŠZŽTUVÕÄÖÜXY1234567890.,"<>?=-:/' CS initial_file+len(1).
CONCATENATE initial_file+len(1) temp into temp.
ENDIF.
ENDDO.