Hashing Secret for Secret Question

Hi,

I am using the secret question example as a blueprint for my own secret question implentation, it all works fine.
I am just having a hard time figuring out how to encrypt the secret answer in the credential table.

I oblivously cannot use the UserCredentialModel way since there is no encrpytion possible.
I tried something like this:

PasswordPolicy policy = context.getRealm().getPasswordPolicy();
context.getSession().setAttribute(“secret_question”, question);
CredentialModel input = new CredentialModel();
input.setType(SecretQuestionCredentialProvider.SECRET_QUESTION);
input.setValue(answer);
input.setHashIterations(27500);
input.setAlgorithm(policy.getHashAlgorithm());
input.setSalt(“fwacyvcrgr”.getBytes());
context.getSession().userCredentialManager().updateCredential(context.getRealm(), context.getUser(), input);
context.success();

But it does not work. And how do I validate against it?

Am I on the right path here?
Would appreciate some help here.

Torsten