About Cakephp Encryption and Decryption

Asked 2 years ago, Updated 2 years ago, 42 views

I'd like to encrypt & decrypt my password using the following functions, but I'd like to use the vendor folder for Crypt.php
Create a Crypt class as the and use the controller to

App::uses('Crypt', 'Vendor');

If you call , you will not find the security class.
How will it work?

class Crypt {
    static public function encrypt($text){
        return base64_encode(Security::rijndael($text,Configure::read('constants.crypt_key'), 'encrypt'));
    }

    static public function decrypt($text){
        return Security::rijndael(base64_decode($text), Configure::read('constants.crypt_key'), 'decrypt');
    }
}

php cakephp

2022-09-29 20:30

2 Answers

Crypt depends on the security class, so

Before Crypt.php Class Definition

App::uses('Security', 'Utility');

Please add


2022-09-29 20:30

Why don't you define components within your controller?

public$components=['Security');


2022-09-29 20:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.