1. Jorge Escobar
  2. PowerBuilder
  3. Monday, 18 February 2019 23:47 PM UTC

Hello,

I followed the example of the help to encrypt in MD5; however, the result is not as expected.

Let's see, this is the example:

Blob lblb_data
Blob lblb_md5
String ls_resultMD5

lblb_data = Blob("Test MD5", EncodingANSI!)

CrypterObject lnv_CrypterObject
lnv_CrypterObject = Create CrypterObject

// Encrypt with MD5
lblb_md5 = lnv_CrypterObject.MD5(lblb_data)

ls_resultMD5	= String(lblb_md5, EncodingANSI!)

sle_result.text	= ls_resultMD5

 

According to https://md5online.es/cifrar-md5 and other means of encryption, the result for "Test MD5" is 17b5cb0adb7fc8a14dbe55c312d84604 however, the result for "Test MD5" obtained from PowerBuilder is µËÛÈ¡M¾UÃØF

 

I use PB 2017 R3 1880

 

Any ideas about it?

Thank you

 

Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 19 February 2019 08:19 AM UTC
  2. PowerBuilder
  3. # 1

Hello Jorge,

you need a CoderObject in between.

Best,

.m

 

Blob lblb_data
Blob lblb_key
Blob lblb_hash
lblb_data = Blob("Test MD5", EncodingANSI!)
lblb_key = Blob("Hashing Test", EncodingANSI!)

lnv_CrypterObject = Create CrypterObject
lnv_CoderObject = Create CoderObject

lblb_hash = lnv_CrypterObject.MD5(lblb_data)
ls_hash = lnv_CoderObject.HexEncode(lblb_hash)
lblb_hash = Blob(ls_hash, EncodingANSI!)

sle_result.Text = String(lblb_hash, EncodingANSI!)

Comment
There are no comments made yet.
Arthur Hefti Accepted Answer Pending Moderation
  1. Tuesday, 19 February 2019 04:40 AM UTC
  2. PowerBuilder
  3. # 2

The website shows the result in HEX. You can use the CoderObject to get the Hex String from a blob:

CoderObject lnv_CoderObject
lnv_CoderObject = Create CoderObject

ls_resultMD5 = lnv_CoderObject.HexEncode( lblb_md5 )

Regards
Arthur

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 19 February 2019 00:33 AM UTC
  2. PowerBuilder
  3. # 3

Hi Jorge; 

   To get this in hex, write the value in the Blob variable to a file & then view the file in a hex editor. You should then see the same values.

HTH

Regards ... Chris

Comment
  1. Roland Smith
  2. Tuesday, 19 February 2019 01:47 AM UTC
That isn't a very good solution. There should be an option to return it as a hex string.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 19 February 2019 17:08 PM UTC
FWIW ... I would personally prefer that the PB Debugger be enhanced to let you view Blob datum in Hex format. ;-)
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 19 February 2019 00:31 AM UTC
  2. PowerBuilder
  3. # 4

My BCrypt example gives the correct result:

http://www.topwizprogramming.com/freecode_bcrypt.html

 

Not sure why the built-in function is like that.

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.