1. Jure Gornjak
  2. PowerBuilder
  3. Wednesday, 1 July 2020 06:00 AM UTC
Dear PB programmers,

I have been successfully using data encryption / decryption functions for a long time and entering them into the SQL database.

I wanted to do the same thing by writing the encrypted data to the Registry (RegistrySet), but in some cases the RegistryGet function does NOT return the correct data.

I use Mr. Roland Smith's n_cryptoapi.of_Encrypt and n_cryptoapi.of_Decrypt functions for encryption.

I am grateful for every hint!
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 1 July 2020 16:27 PM UTC
  2. PowerBuilder
  3. # 1

Jure -

   Did you see Roland Smith's response?

Delete the two values and change your code to store it as RegBinary! with the encrypted string coming from a blob variable. Then you use RegBinary! with RegistryGet and convert to string.


Later -

Olan

Comment
  1. Jure Gornjak
  2. Wednesday, 1 July 2020 18:01 PM UTC
Hi Olan ,



I saw I was going to test Roland's proposal in the coming days.

  1. Helpful
  1. Jure Gornjak
  2. Friday, 3 July 2020 06:12 AM UTC
Thanks to everyone who helped solve this problem in any way.

The winning proposal is of course from Roland Smith, that is the use of the Blob variable with RegBinary! parameter.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 1 July 2020 13:31 PM UTC
  2. PowerBuilder
  3. # 2

Quote:

I wanted to do the same thing by writing the encrypted data to the Registry (RegistrySet), but in some cases the RegistryGet function does NOT return the correct data.

1. After RegistryGet fails, do you find the value in the registry using "regedit.exe"?

2. Define "some cases": Is that for certain users, or on the same PC it can fail sometimes?

3. To which part of the registry are you writing. Lots of users have LOCAL_MACHINE protected for write.

 

Comment
There are no comments made yet.
Jure Gornjak Accepted Answer Pending Moderation
  1. Wednesday, 1 July 2020 12:02 PM UTC
  2. PowerBuilder
  3. # 3

Hi Marco ,

This is the registry location (ALT PrintScreen),

blue data is NOT properly encrypted/decrypdet (Pokopalisce and Vodarina) , the error is seen in the length of the encrypted data, the password is the same for all data.
 
Dimamicni menu and NUSZ is OK !
 

Comment
  1. Roland Smith
  2. Wednesday, 1 July 2020 13:30 PM UTC
Delete the two values and change your code to store it as RegBinary! with the encrypted string coming from a blob variable. Then you use RegBinary! with RegistryGet and convert to string.
  1. Helpful
  1. Marco Meoni
  2. Wednesday, 1 July 2020 13:31 PM UTC
Hi,

n_cryptoapi::of_encrypt returns Hex-encoding values

> return of_Blob2Hex(lblb_Encrypted)

The values you have in the registry are not Hex-encoded.

Best,

.m
  1. Helpful
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Wednesday, 1 July 2020 10:10 AM UTC
  2. PowerBuilder
  3. # 4

what's the registry location?

Maybe you have a 32/64 bit location/permission issue (i.e. WOW6432Node hive)?

Best,

.m

Comment
There are no comments made yet.
Jure Gornjak Accepted Answer Pending Moderation
  1. Wednesday, 1 July 2020 08:23 AM UTC
  2. PowerBuilder
  3. # 5

Hi Marco ,

Thanks for the quick reply .

- what's the return code from RegistryGet?

1

- can you see the value from Regedit?

yes

- is the encrypted value a plain string (e.g. using n_cryptoapi Hex encoding) or not? You may need to try RegString!, RegExpandString!, RegBinary!, RegMultiString! depending on the encrypted sequence of bytes that you store.

yes plain string with RegString! parameter

 

 

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Wednesday, 1 July 2020 08:05 AM UTC
  2. PowerBuilder
  3. # 6

Hi Jure,

- what's the return code from RegistryGet?
- can you see the value from Regedit?
- is the encrypted value a plain string (e.g. using n_cryptoapi Hex encoding) or not? You may need to try RegString!, RegExpandString!, RegBinary!, RegMultiString! depending on the encrypted sequence of bytes that you store.

Best,

.m

 

P.S.

PB now provides built-in object for encryption, you do not need Windows DLL and external functions any more:

https://docs.appeon.com/pb2019r2/objects_and_controls/ch02s15.html

 

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.