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

Using function module MD5_CALCULATE_HASH_FOR_CHAR for cyrillic characters

Former Member
0 Likes
2,326

Hey SAPlers!

I recently tried to use the function module 'MD5_CALCULATE_HASH_FOR_CHAR' for cyrillic characters, but unfortunately noticed that different strings produce the same hash. Is this because the codepage is different? If so, how can I still use cyrillic characters?

See the sample code below.

REPORT Z_TEST_HASH.


DATA: string1 TYPE string VALUE 'CUS&ДЕКЛT9',
      string2 TYPE string VALUE 'CUS&КОРРT9',
      hash1(32) TYPE c,
      hash2(32) TYPE c.


CALL FUNCTION 'MD5_CALCULATE_HASH_FOR_CHAR'
    EXPORTING
      data           = string1
    IMPORTING
      hash           = hash1
    EXCEPTIONS
      no_data        = 1
      internal_error = 2
      OTHERS         = 3.

CALL FUNCTION 'MD5_CALCULATE_HASH_FOR_CHAR'
    EXPORTING
      data           = string2
    IMPORTING
      hash           = hash2
    EXCEPTIONS
      no_data        = 1
      internal_error = 2
      OTHERS         = 3.

BREAK-POINT.

Hey SAPlers!

I recently tried to use the function module 'MD5_CALCULATE_HASH_FOR_CHAR' for cyrillic characters, but unfortunately noticed that different strings produce the same hash. Is this because the codepage is different? If so, how can I still use cyrillic characters?

See the sample code below.

REPORT Z_TEST_HASH.


DATA: string1 TYPE string VALUE 'CUS&ДЕКЛT9',
      string2 TYPE string VALUE 'CUS&КОРРT9',
      hash1(32) TYPE c,
      hash2(32) TYPE c.


CALL FUNCTION 'MD5_CALCULATE_HASH_FOR_CHAR'
    EXPORTING
      data           = string1
    IMPORTING
      hash           = hash1
    EXCEPTIONS
      no_data        = 1
      internal_error = 2
      OTHERS         = 3.

CALL FUNCTION 'MD5_CALCULATE_HASH_FOR_CHAR'
    EXPORTING
      data           = string2
    IMPORTING
      hash           = hash2
    EXCEPTIONS
      no_data        = 1
      internal_error = 2
      OTHERS         = 3.

BREAK-POINT.
1 REPLY 1
Read only

cris_hansen
Product and Topic Expert
Product and Topic Expert
1,580

Hi Fredrik,
Have you tried class CL_ABAP_MESSAGE_DIGEST?

FM MD5_CALCULATE_HASH_FOR_CHAR has status "Not Released", so it should not be used (SAP Note 109533).

Regards,

Cris