CodeExchange

Appeon Community. PowerBuilder - Appeon Community
  1. These days I have been racking my brain to encrypt sensitive data in my programs, the passwords that are stored in the database, or the connection data to the database that in many PowerBuilder applications that I have seen are stored in . ini without any protection.

    At first I thought of using a simplification of PowerBuilder's CrypterObject, putting a Fixed Key and a fixed Initiation Vector to use the SymetricEncrypt function. Then I realized that my programs are uploaded to GitHub in a plain text file and my decryption keys were going to be exposed there, so I thought about moving these to the .ini file as could be done in a .Net Api in the that we would store the connection data in the AppSetting.json configuration file.

    But this option did not convince me either, since if I put the encryption keys and connection string values ​​encrypted with those keys in the same file, anyone could decrypt those values.

    So I thought about encrypting the Key and the Vector within a Json in the style of a Token, so that the application only has in the code a master key and a master vector that only serves to decrypt that token that in turn provides us the key and the initiation vector to encrypt and decrypt from our app.

    A bit of the scheme to apply in an application would be:

    blogger.googleusercontent.com/img/b/R29v...dw/s1082/esquema.png

    I have also incorporated a very useful feature: the ability to Autogenerate Keys. This means they can now automatically generate the Key and Vector for both the application and the JSON.

    As always, I leave you the current project link on GitHub:

    github.com/rasanfe/EncryptGenerator

    Attached here is the project compiled today in PowerBuilder 2022R3 Build 3356.

    I always recommend going to the github links to find the latest version.

    To be aware of what I publish you can follow my blog in Spanish:

    rsrsystem.blogspot.com
  2. The examples uploaded to the site are both compiled for .Net Standard 2.0. I believe that means .Net Framework 4.7.1.

    The most recent version of the library I'm wrapping is .Net 6, so if you wanted to upgrade the component you would need to move to that.
  3. Today I would like to share a small example that I made to be able to fill out Form 145 for my company's employees automatically.
    (This model is used in Spain to declare family and personal data to the company to calculate personal income tax withholding on the payroll, that is, taxes)

    Every year our advisor sends us this form so that we can give it to the employees and they can return it to us completed. To speed up this process, I decided to implement a method that would automate the filling out of the data, generating a personalized PDF for each employee.

    The solution we present today is a simplified version of this process. Basically, it consists of a WebBrowser control that allows you to view the PDF of the form and two buttons that make it easier to obtain and write the fields.

    The first button, called "Get Form Fields", has the function of detecting the fillable fields of the PDF. Clicking on it will display a Messagebox with the name of all identified fields. Additionally, to facilitate programming in the next button, this button copies a code snippet to the clipboard containing the names of the identified fields and the variables associated with their data as follows:

    ls_FormFields[1] = "genter_nif"
    ls_FormData[1] = ""

    ls_FormFields[2] = "genter_compuesto"
    ls_FormData[2] = ""

    ls_FormFields[3] = "genter_anyo_nacimiento"
    ls_FormData[3] = ""
    ...

    This simplifies the process of manually filling out the fields programmatically.

    The second button, called "Fill Form Fields", allows you to automate the process of filling out the fields. In the example provided, this button is programmed to complete the attached form "Modelo145.pdf", but you can easily modify the example to fill out any other form supported by the first button.

    I want to emphasize that the attached form "Modelo145.pdf" is not an official template with fillable fields, but that I have created them personally with the names that I found convenient. However, this adaptation has been very useful to speed up work in my company. Remember that this example is just a simplified sample to illustrate the process of automating PDF form filling. If you decide to use it for your own forms, be sure to adjust the field names and associated data accordingly.

    By the way, the .Net library that I used to create this example is iTextSharp(5.5.13.3) and I have compiled it in .Net6, I have tried to do the same with iText7 but without success, it gives me a strange error when using the library from PowerBuilder as with the digital signature example. Let's see if someone is encouraged and tries to solve it....

    As always, I leave you the current project link on GitHub:

    github.com/rasanfe/pbPdfFillFormFields

    And project in Visual Studio 2022:

    github.com/rasanfe/PdfFillFormFields

    Attached here is the project compiled today in PowerBuilder 2022R3 Build 3356 along with the Visual Studio Project.

    I always recommend going to the github links to find the latest version.

    To be aware of what I publish you can follow my blog in Spanish:

    rsrsystem.blogspot.com
  4. Attached is the sample code demoed in the video: Adding a QR Code Library into your PowerBuilder Application.
    Here is the link for the video:
  5. Thanks Bruce
    I since found the below url that appears to work
    api.qrserver.com/v1/create-qr-code

    And was able to just replace the google api with it. ie

    ls_chart_url = ' api.qrserver.com/v1/create-qr-code/?size= ' + String ( width ) + 'x' + String ( height ) + '&data=' + ls_provision_url

    We may use this as a quick interim solution until we look at integrating your QR dll.

    Kind regards
    Rob