public static function encryptDataKeyAndPutIntoSession(Request $request, User $user, $password, $salt) { $key = Key::CreateKeyBasedOnPassword($password, $salt); $encryptedKey = $user->getDataKey(); $asciiDataKey = Crypto::decrypt($encryptedKey, $key, true); $dataKey = Key::LoadFromAsciiSafeString($asciiDataKey); $request->getSession()->set(AuthSuccessHandler::SESSION_KEY_DATA_KEY, $dataKey); return $dataKey; }