1. David Vasconcelos
  2. PowerBuilder
  3. Wednesday, 23 May 2018 11:18 AM UTC

Not sure if I am doing something wrong... I was trying out one of Roland Smiths objects for encryption, works fine in PB12.5 but fails when converted to Appeon Web.  Looks like it hangs up on the CRYPTCREATEHASH api..error 126 - module not found.  Microsoft mentions that this has been deprecated and use the next gen api's.

Question1: Has anyone used his objects and got them to work for appeon web?
Question2: Am I using the wrong version of it.  (Using: cryptoapi).

Question3: What other alternatives can be used that will work in Appeon Web.

Thanks in advance...

Dave V

Andres Slachevsky Accepted Answer Pending Moderation
  1. Wednesday, 23 May 2018 12:43 PM UTC
  2. PowerBuilder
  3. # 1

I´m using the "crypt32.dll" with appeon 2016 WEB

and it works perfect

Local External Functions:
 

FUNCTION boolean CryptBinaryToString ( &
    Blob pbBinary, &
    ulong cbBinary, &
    ulong dwFlags, &
    Ref string pszString, &
    Ref ulong pcchString ) &
LIBRARY "crypt32.dll" ALIAS FOR "CryptBinaryToStringA;Ansi"

FUNCTION boolean CryptStringToBinary ( &
    string pszString, &
    ulong cchString, &
    ulong dwFlags, &
    Ref blob pbBinary, &
    Ref ulong pcbBinary, &
    Ref ulong pdwSkip, &
    Ref ulong pdwFlags ) &
LIBRARY "crypt32.dll" ALIAS FOR "CryptStringToBinaryA;Ansi"

FUNCTION long GetComputerNameW &
    (ref string ComputerName, ref ulong BufferLength) &
  LIBRARY "KERNEL32.DLL"
FUNCTION long GetUserNameW(ref string UserName, ref ulong BufferLength) &
LIBRARY "ADVAPI32.DLL"

instance Variables
 

// Base64, with certificate beginning and ending headers
CONSTANT Ulong CRYPT_STRING_BASE64HEADER = 0

// Base64, without headers
CONSTANT Ulong CRYPT_STRING_BASE64 = 1

// Pure binary copy
CONSTANT Ulong CRYPT_STRING_BINARY = 2

// Base64, with request beginning and ending headers
CONSTANT Ulong CRYPT_STRING_BASE64REQUESTHEADER = 3

// Hexadecimal only
CONSTANT Ulong CRYPT_STRING_HEX = 4

//  Hexadecimal, with ASCII character display
CONSTANT Ulong CRYPT_STRING_HEXASCII = 5

// Base64, with X.509 CRL beginning and ending headers
CONSTANT Ulong CRYPT_STRING_BASE64X509CRLHEADER = 9

// Hexadecimal, with address display
CONSTANT Ulong CRYPT_STRING_HEXADDR = 10

// Hexadecimal, with ASCII character and address display
CONSTANT Ulong CRYPT_STRING_HEXASCIIADDR = 11

// A raw hex string. WinServer 2K3, WinXP:  This value is not supported.
CONSTANT Ulong CRYPT_STRING_HEXRAW = 12

 

Comment
  1. David Vasconcelos
  2. Thursday, 31 May 2018 11:54 AM UTC
Thanks Chris, I will look into it. 

  1. Helpful
  1. Miguel Leeuwe
  2. Tuesday, 23 April 2019 13:15 PM UTC
Hi Chris,

I've gone through the same trouble. Would your simple encryption/decryption mechanism need any modifications for them to work on powerserver web?



regards,

Miguel
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 23 April 2019 18:23 PM UTC
Hi Miguel;

No .. the "simple" encryption mechanism is all coded in pure native PowerScript and works on both the PS Web and Mobile applications. Note that in my framework, the "simple" encryption and decryption feature is implemented via the "fn_decrypt_simple" and "fn_encrypt_simple" global functions. So you could just copy these functions from my framework over to your App(s) & use them "as is". ;-)

Also, I have a complete framework encryption / decryption example as well if you would like to review that code now or in the future: https://sourceforge.net/projects/stdfndclass/files/Applications/PowerBuilder/Cryptography

Regards ... Chris
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 23 May 2018 19:06 PM UTC
  2. PowerBuilder
  3. # 2

I have two encryption examples:

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

and

CryptoAPI: http://www.topwizprogramming.com/freecode_cryptoapi.html

Try both of them.

Comment
  1. David Vasconcelos
  2. Thursday, 24 May 2018 10:15 AM UTC
No luck, get error. BCRYPTGetProperty - BCRYPT-OBJECT-LENGTH , null error.

  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 30 January 2019 09:40 AM UTC
  2. PowerBuilder
  3. # 3

I have the same problem as David:

Base 64 encoding with CryptBinaryToString results in error 126.

 

My code:

Function Boolean CryptBinaryToString ( &
    blob pbBinary, &
    ulong cbBinary, &
    ulong dwFlags, &
    Ref string pszString, &
    Ref ulong pcchString) Library "Crypt32.dll" Alias For "CryptBinaryToStringW"




CONSTANT ulong        CRYPT_STRING_BASE64     = 1
CONSTANT ulong        CRYPT_STRING_NOCRLF     = 1073741824


Blob         lblob_value

string     ls_result

uLong     lul_buflen



ls_result = Space (2 + 1.5 * (Len (lblob_value) + 2))
lul_buflen = Len (ls_result)

CryptBinaryToString (lblob_value, Len (lblob_value), CRYPT_STRING_BASE64 + CRYPT_STRING_NOCRLF, ls_result, lul_buflen)

 

It runs well if I run the application as classic Powerbuilder Application. But if I deploy it to the web it will not work.

 

Any idea?

I can't use new CodeObject because it is unsupported in Powerserver.

 

 

 

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 30 January 2019 22:25 PM UTC
Hi Rene;

Unfortunately, the new CoderObject in PB 2017R3 is not included in the new PS 2019 release just coming out. The PS2019 release will include support for the HTTPClient, JSONGenerator, JSONParser and RESTClient object classes (Web Only).

Regards ... Chris

  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 31 January 2019 12:17 PM UTC
  2. PowerBuilder
  3. # 4

I found out that the blob I wanted to convert to Base64 is empty.

The reason is that a conversion of a byte array to a blob fails in Powerserver.

Comment
  1. René Ullrich
  2. Monday, 4 February 2019 08:05 AM UTC
FYI: Workaround for converting byte array to blob is to set each single byte using SetByte function.
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Sunday, 3 March 2019 18:18 PM UTC
  2. PowerBuilder
  3. # 5

FYI - am using roland's bcrypt in rest requests and it converts back and forth with base64 to/from blob.

i had trouble getting it to work, and after hours of testing, i finally narrowed down that setnull was the problem.   Just by setting a blob variable to NULL - setnull( blobvariable) - made the blob variable unusable in powerserver (works fine in powerbuilder).  I had been using setnull() then calling the base64 decrypt api.  If i either didn't call setnull, or if i set the blob to something using powerscript then it worked: lblob = blob('')

 

PS 2016

 

 

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.