javajooqjooq-codegen

How to apply MySQL cryptography functions in Jooq custom Converter?


I'm trying to achieve below using Jooq library,

Currently I'm trying to do this using org.jooq.Converter and org.jooq.meta.jaxb.ForcedType But

Links I'm referring to:

Update: In short this is what I'm trying to achieve through Jooq:

CREATE TABLE TESTCRYPT(
Id mediumint AUTO_INCREMENT,
Secret int NOT NULL,
encrypteddata BLOB,
PRIMARY KEY(Id)
);

INSERT INTO TESTCRYPT(Secret,encrypteddata) VALUE ('1234',AES_ENCRYPT('my-data','1234'));

SELECT Secret ,AES_DECRYPT(encrypteddata,Secret) from TESTCRYPT t ;


Solution

  • An out of the box feature

    As of jOOQ 3.18, there isn't an out of the box feature for this sort of computation. I've created a feature request, as this isn't the first time someone was looking for it:

    Custom implementation on the server side

    If you must encrypt / decrypt on the server side using SQL expressions, perhaps you can get away with the new experimental query object model traversal and replacement features.

    The idea is that you:

    Custom implementation on the client side

    All of this seems much easier to achieve with a simple Converter, if you can encrypt / decrypt on the client instead of the server.