Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
45 | public function generate() |
||
46 | { |
||
47 | $boxKp = \Sodium\crypto_box_keypair(); |
||
48 | $obj = new static; |
||
49 | $obj->secret = \base64_encode(\Sodium\crypto_box_secretkey($boxKp)); |
||
50 | $obj->hash = \hash('sha256', uniqid('__EncryptionKeyPairHash', true)); |
||
51 | |||
52 | if ($obj->save()) { |
||
53 | return $obj; |
||
54 | } |
||
55 | |||
56 | throw new \yii\base\Exception(Yii::t('yrc', 'Failed to generate security tokens')); |
||
57 | } |
||
58 | } |