1. Cecilia Jiménez Bedoya
  2. PowerBuilder
  3. Tuesday, 28 November 2017 11:39 AM UTC

Hello, I use this code in in PB12.5 NET 

System.Security.Cryptography.SHA1Managed  sha1
sha1 = create System.Security.Cryptography.SHA1Managed()

System.Byte hash[] , lb[]
 hash = sha1.ComputeHash(lb) 

How can I do the same in PB2017? Thank you.

 


 

Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 28 November 2017 13:17 PM UTC
  2. PowerBuilder
  3. # 1
Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Tuesday, 28 November 2017 15:31 PM UTC
  2. PowerBuilder
  3. # 2

Hi,
that is a tricky matter, the classes you refer to is part of the .NET Framework. 
Any related function (such as your System.Security.Cryptography.SHA1) needs to be exposed by a COM visible object in order to be used from PB Classic.

Instead, the link provided by Roland points to Win32 functions, that are NOT .NET managed libraries. Win32 functions are legacy, old and not as safe/secure as .NET libs.
So, if you can find there a function equivalent to SHA1 that computes the hash for the given input data, you are fine.

But it is not the same as using the .NET System.Security.

If you want to go for a native .NET library you have to:
1) build up a COM Visible wrapper from Visual Studio, have some background knowledge here:

https://community.appeon.com/index.php/articles-blogs/tips-tricks-techniques-articles/17-powerbuilder/167-calling-net-components-from-powerbuilder-via-com-wrappers-redux

2) Once you have registered the COM object you can use the PB ConnectToNewObject to instantiate it and use the functions that you have wrapped (such as SHA1Managed).

Cheers,
Marco

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.