AnsweredAssumed Answered

Run a php script on a field in each record

Question asked by john Fieldsend on May 7, 2020
Latest reply on May 12, 2020 by john Fieldsend

Hey all, I need to hash a field in my custome module but need sugar to hash the field in every record and save the hash over the original value

 

My php script to hash 

    public function obfuscate($action, $string) 
    {
        $output               = false;
        $encrypt_method     = "AES-256-CBC";
        $key           = hash('sha256', self::$salts[0]);
        $iv                     = substr(hash('sha256', self::$secret_iv), 0, 16);

        if ($action == 'encrypt') {
            $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
            $output = base64_encode($output);
        } else if ($action == 'decrypt') {
            $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
        }
        return $output;
    }

 I just wandered how id call a php function, would  need to create a custom button on the records view 

Outcomes