MessageDigest in VB/C# using UiPath

Hi guys, I have a JAVA code that works perfect for Digesting string. Now I have tried changing it to fit in UiPath, they both work but producing different results. See below original JAVA code and how I change it to fit in UiPath.

IN JAVA:

       String dgStr = "TestingStringDigestion";

       byte[] enc = MessageDigest.getInstance("SHA-256").digest(dgStr.getBytes());

       Console.WriteLine( new String(Base64.encodeBase64(enc)) );

IN UIPATH:

       Assign Activity |=>  dgStr = "TestingStringDigestion"

    Hash Text Activity |=>  Algorithm = SHA256  :  Text = dgStr
       Assign Activity |=>  dgStrBytes [] = Encoding.UTF8.GetBytes(dgStrBytes)
       Assign Activity |=>  dgStrFLN = String.Join("", dgStrBytes)

   Write Line Activity |=>  System.Convert.ToBase64String(dgStrFLN).ToString

I would like know is the conversion above correct, and why does it produce different results.

Hi,

How about the following?

img20210512-5

Sequence.xaml (5.6 KB)

Regards,

Thanks @Yoichi , I have tested and gives me impressive results.

I tested with str = “4534apikey20210511112200”

8HnY2LtSzryi7Ls0hIToBEAfV1QZ7BM7pg8tdNewj/I= (Results in JAVA)
20LfpgXlT05Aw228mq8x+/4otMxs919XNOQ8cLYGHGo= (Results in UiPath)

I have observer that they are not the same, although they have same length.

Is this normal / OK ?

Hi,

In UiPath way, we can check its steps using online sites as the following.

First, calculate SHA256
https://emn178.github.io/online-tools/sha256.html

Then, encode Base64.

https://base64.guru/converter/encode/hex

Can you check which is difference with UiPath about sha256 or base64encode in Java?

Regards,

Thank you @Yoichi , I checked and found out there ok. It was the date that was changing on the java code. I appreciate your help.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.