Custom logic when create user

Hello! We create users with rest api. Before creating a user (immediately after receiving the creation data), we need keycloak go to our service and decrypt the login and password, which will be transfer in encrypted form. After received a response with decrypted data it can created a user. How can we add such functionality to the keycloak code and where should it be done?

There is one extension I know out there for migrating old user stores to Keycloak: