Encrypted Form: How to decrypt data with C#

  • JFRoberto
    Asked on December 1, 2018 at 6:31 PM

    Hi 

    I try to decrypt the data of a form using c # RSACryptoServiceProvider.

    I get the error "the data to be decrypted exceeds the maximum for this modulus of 128 bytes"

    You can provide an example c # code for decoding the values retrieved from a form.

    Thanks in advance

  • Mike
    Replied on December 2, 2018 at 12:39 AM

    At this time we have only a PHP code example to decrypt the data:

    class Decryption
    {
    private $privateKey = '{yourPrivateKey}';
    public
    function decryptSegment($data)
    {
    if (openssl_private_decrypt(base64_decode($data) , $decryptedData, $this->privateKey)) return $decryptedData;
    return "ERROR 1000: Decryption failed!";
    }
    function decrypt($data)
    {
    $decrypted_string = '';
    $string_parts = preg_split("/#Jot#/", $data);
    }
    foreach($string_parts as $str)
    {
    $decrypted_string.= $this->decryptSegment($str);
    }
    return $decrypted_string;
    }
    }

    I have escalated a ticket to see if we can create a C# example. Althrough, we cannot provide a ETA for when this will be addressed.

    We will get back to you via this thread if we have any updates.

  • JFRoberto
    Replied on December 2, 2018 at 4:15 AM

    Hi Mike 

    thank you for the sample, but I can't use PHP in my project.

    So I have another question,

    I read at this link

    https://www.jotform.com/help/344-Encrypted-Forms-and-How-to-Use-Them

    that I can create my Public and Private Key and post it.

    The question is :

    Can generate the Key with another tool (dll) that is not openssl, for c# there is System.Security.Cryptography.RijndaelManaged then generate XML file (not PEM) ?


  • Mike
    Replied on December 2, 2018 at 9:28 AM

    Looks like that Rijndael algorithm is similar to AES, so I think that the RijndaelManaged Class will not work since we use RSA based encryption.

    We use RSA 2048-bit keys. In theory, you can upload your own RSA 2048 key generated with some library other than OpenSSL. However, we recommend using the OpenSSL.

    Encrypted Form: How to decrypt data with C# Image 1 Screenshot 20