Skip to Content
0
Dec 30, 2022 at 08:34 PM

Convert the hash value from array of 32 bytes to hexadecimal string of 64 characters

418 Views

Hi ALL,

I have a request from my company to create a hash value of the normalized text using SHA256 and then convert the hash value from an array of 32 bytes to a hexadecimal string of 64 characters and last use the hexadecimal as a string

here is my code :

DATA(lv_algo) = |SHA256|.

DATA(lv_data) = lv_boy2. "|lv_boy2|.

DATA: lv_hashstring TYPE string.

DATA: lv_hashxstring TYPE xstring.

DATA: lv_hashb64string TYPE string.

cl_abap_message_digest=>calculate_hash_for_char( EXPORTING

if_algorithm = lv_algo

if_data = lv_data

IMPORTING

ef_hashstring = lv_hashstring

ef_hashxstring = lv_hashxstring

ef_hashb64string = lv_hashb64string ).

then I use lv_hashstring and convert it to hex 64 characters

image.png

I am asking if that code is correct because I think I miss something

Attachments

image.png (4.9 kB)