Calculate a hash in ABAP

by | Dec 29, 2019 | ABAP Programs

Home » SAP » ABAP » ABAP Programs » Calculate a hash in ABAP

Preface – This post is part of the ABAP Programs series.

In ABAP we can perform the following:

calculate_hash_for_raw

METHOD calculate_hash_for_raw.
    TRY.
        cl_abap_message_digest=>calculate_hash_for_raw(
          EXPORTING
            if_algorithm = 'SHA256'
            if_data      = iv_data
          IMPORTING
            ef_hashstring = ev_sha256
        ).
      CATCH cx_root.
        " Eh, what're you gonna do?
    ENDTRY.
  ENDMETHOD.

calculate_hash_for_string

METHOD calculate_hash_for_string.
    TRY.
        cl_abap_message_digest=>calculate_hash_for_char(
          EXPORTING
            if_algorithm = 'SHA256'
            if_data      = iv_data
          IMPORTING
            ef_hashstring = ev_sha256
        ).
      CATCH cx_root.
        " Eh, what're you gonna do?
    ENDTRY.
  ENDMETHOD.

 

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author