1. Samuel Sanchez Avila
  2. SnapDevelop
  3. Tuesday, 31 August 2021 22:35 PM UTC

Hello

This is something specific, we are migrating some process to C#, but there is some Encryt/Decrypt code in PB that we would want to have something similar with c#, could someone tells us how to translate this section? same public/private keys, data...

 

thanks

 

 


lblb_data= inv_CoderObject.Base64decode(as_data)

// Decrypt data using RSA
lblb_decrypt = inv_CrypterObject.AsymmetricDecrypt(RSA!,lblb_data, ab_pvkey) //ab_pvkey = private key in blob variable

ls_text =  string(lblb_decrypt, EncodingANSI!)

Accepted Answer
Samuel Sanchez Avila Accepted Answer Pending Moderation
  1. Tuesday, 7 September 2021 14:38 PM UTC
  2. SnapDevelop
  3. # Permalink

PRIVATE and PUBLIC KEY has a PKCS8 RSA format, so then in c#, there a function, rsa.ImportPKCS8PRIVATEKEY, thats the way to import these key generated with PB, in other way, keys will be useless, obtaining errores such like: data lenght exceeds limit to encrypt/decrypt, data no valid, keys no valid.

Comment
  1. Armeen Mazda @Appeon
  2. Tuesday, 7 September 2021 16:13 PM UTC
Thanks for sharing the solution!
  1. Helpful
  1. Francisco Martinez @Appeon
  2. Tuesday, 7 September 2021 16:33 PM UTC
Samuel, thanks for sharing the solution to the problem. Glad it's working for you now



Regards,

Francisco
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 1 September 2021 13:46 PM UTC
  2. SnapDevelop
  3. # 1

Hi Samuel,

C#'s RSACryptoServiceProvider might offer the functionality you're looking for. Here's the link to Microsoft's documentation. It has examples on encrypting and decrypting.

Please let me know if this helps.

Regards,
Francisco

Comment
  1. Samuel Sanchez Avila
  2. Thursday, 2 September 2021 14:48 PM UTC
Does Snap Developer has something equivalente to Crypter Object?

  1. Helpful
  1. Francisco Martinez @Appeon
  2. Thursday, 2 September 2021 18:46 PM UTC
Hi Samuel,

the 128-byte limitation is because of how the RSA algorithm works. Indeed the question is why does it work in PowerBuilder. I'm gonna ask the team about this and get back to you as soon as I hear from them.

Regards,

Francisco
  1. Helpful 1
  1. Samuel Sanchez Avila
  2. Thursday, 2 September 2021 20:14 PM UTC
Thanks you very much! im gonna try this crypto with any other data lower size to make work this rsa encrypt/decrypt
  1. Helpful
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.