当我们使用CSecurityManager::encrypt对字符串进行加密, 加密后的字符串是一串乱码(看起来确实像乱码, 具体是什么有待考证), 这不利于我们的下一步操作.


我们可以使用base64处理加密后的字符串, 处理后的字符串是由字母和数字组成 如果


$securityManager = Yii::app()->getSecurityManager();


$encrypted = base64_encode( $securityManager->encrypt(encryptString) );


如果要解密, 需要先使用base64_decode对加密串进行处理


$securityManager->decrypt(base64_decode($encrypted));