【发布时间】:2012-08-07 13:59:05
【问题描述】:
我正在尝试在我的模型的 beforeSave 方法中加密一些数据。但它没有被保存。
$currentBalance = $this->find("all", array(
"fields" => array(
"SUM(base_amount) as 'CurrentBalance'"
),
"conditions" => array(
"Payment.user_id" => $this->data["Payment"]["user_id"]
)
));
$this->log($this->data["Payment"]);
$this->log(Configure::read("Security.salt"));
$this->log(Security::cipher(implode("|", $this->data["Payment"]), Configure::read("Security.cipherSeed")));
$this->set("balance", $currentBalance[0][0]["CurrentBalance"] + $this->data["Payment"]["base_amount"]);
$this->set("balance_checksum", Security::cipher(implode("|", $this->data["Payment"]), Configure::read("Security.salt")));
如果我查看日志文件,我会得到某种加密数据,但都是乱码。
虽然在数据库中,但我一无所获。
如果我用一个简单的字符串替换密码函数,比如“123”......那将被正确保存。
我已确保数据库连接是 utf8 编码的,并且数据库中的字段具有 utf8 排序规则。
任何关于此的指针都会很棒
谢谢
【问题讨论】:
标签: cakephp