How to use EncryptByCert ?

Posts   
 
    
MattE avatar
MattE
User
Posts: 77
Joined: 11-Sep-2007
# Posted on: 17-Dec-2008 18:11:22   

I am currently overriding my entity's OnSave event as follows:

 protected override void OnSave()

            try
            {
                IEntityField field = this.Fields[(int)CreditCardFieldIndex.Pan];
                field.SetExpression(new DbFunctionCall("ENCRYPTBYCERT", new object[] { "XXX", field.CurrentValue }));
            }
            catch (Exception e)
            {
                EventLogger.LogError(e,"CreditCardEntity OnSave failed");
            }
            base.OnSave();
        } 


XXX represents the valid certificate id,

With no success, the generated SQL does not include the EncryptByCert function

We're using the LLBLGEN 2.6 runtimes, self-servicing.

Thank you

MattE avatar
MattE
User
Posts: 77
Joined: 11-Sep-2007
# Posted on: 17-Dec-2008 18:32:55   

Sorry, I realized that the first parameter is also a function call, so the code should look like this:

        protected override void OnSave()
        {
            try
            {
                IEntityField field = Fields[(int)CreditCardFieldIndex.Pan];
                DbFunctionCall certId = new DbFunctionCall("CERT_ID", new object[] { "XXX" });
                field.SetExpression(new DbFunctionCall("ENCRYPTBYCERT", new object[] { certId, field.CurrentValue.ToString()  }));
            }
            catch (Exception e)
            {
                EventLogger.LogError(e,"CreditCardEntity OnSave failed");
            }
            base.OnSave();
        } 
     }

but still nothing in the generated sql ...

Thanks,

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-Dec-2008 20:45:15   

There's currently a thread going on about encryption/decryption of columns. See: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14929

Frans Bouma | Lead developer LLBLGen Pro