Jump to:

21298 Posts in 5735 Topics by 2603 members

General Questions

SilverStripe Forums » General Questions » Encrypting Data using OnBeforeWrite

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 1482 Views
  • zenmonkey
    Avatar
    Community Member
    483 Posts

    Re: Encrypting Data using OnBeforeWrite Link to this post

    I use it in Model Admin as well I just add the following function to my object
    http://pastie.org/3856863

    Then all you have to do is create a custom getter for the value to decrypt it. For instance if you encypted a field called FirstName just create:

    protected function getFirstName() {
       $toDecrypt = $this->getField("FirstName");
       
        /* Decrypt encrypted string */
          $decrypted = $this->decryptInfo($toDecrypt);
          
          return $decrypted;
          
    }

    This is good because if you need to call FirstName in a FrontEnd template it will work as well

  • cumquat
    Avatar
    Community Member
    159 Posts

    Re: Encrypting Data using OnBeforeWrite Link to this post

    You sir are a star.....

    Got it working although not on the memberextension decorator but that will hopefully just be a small tweak but got it working on a standard dataobject.

    Thanks again for your help and patience.

    Mick

    1482 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.