- Posts: 21
- Thank you received: 5
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Question attribute "Encrypted" is used to enable data encryption
- MikhailGorbunov
- Topic Author
- Offline
- Junior Member
Less
More
6 months 1 week ago #251168
by MikhailGorbunov
Question attribute "Encrypted" is used to enable data encryption was created by MikhailGorbunov
Please help us help you and fill where relevant:
Your LimeSurvey version: [5.6.40]
Own server or LimeSurvey hosting: own
==================
How to show respondent answers from database in external .php file if question attribute "Encrypted" is used to enable data encryption?
select id, submitdate, AES_DECRYPT(1X2X3SQ001, 'key'); returns NULL
Your LimeSurvey version: [5.6.40]
Own server or LimeSurvey hosting: own
==================
How to show respondent answers from database in external .php file if question attribute "Encrypted" is used to enable data encryption?
select id, submitdate, AES_DECRYPT(1X2X3SQ001, 'key'); returns NULL
Please Log in to join the conversation.
- MikhailGorbunov
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 5
6 months 1 week ago #251169
by MikhailGorbunov
Replied by MikhailGorbunov on topic Question attribute "Encrypted" is used to enable data encryption
Tryed
require_once '/path/vendor/autoload.php'; // Adjust the path to the autoload.php file
use LimeSurvey\Survey\Repository as SurveyRepository;
use LimeSurvey\Token\Provider as TokenProvider;
$surveyRepository = new SurveyRepository();
$tokenProvider = new TokenProvider();
$surveyId = 123;
$tokens = $tokenProvider->getTokens($survey);
foreach ($tokens as $token) {
$participantToken = $token->getToken();
$responseData = $tokenProvider->getResponseData($survey, $participantToken);
// Display the participant's token
echo "Token: $participantToken <br>";
// Display the question answers
foreach ($responseData as $questionId => $questionData) {
echo "Question ID: $questionId <br>";
foreach ($questionData as $subQuestionId => $answer) {
echo "Sub-Question ID: $subQuestionId <br>";
echo "Answer: $answer <br>";
}
}
echo "<br>";
}
with LimeSurvey\Survey\Repository not found error.
require_once '/path/vendor/autoload.php'; // Adjust the path to the autoload.php file
use LimeSurvey\Survey\Repository as SurveyRepository;
use LimeSurvey\Token\Provider as TokenProvider;
$surveyRepository = new SurveyRepository();
$tokenProvider = new TokenProvider();
$surveyId = 123;
$tokens = $tokenProvider->getTokens($survey);
foreach ($tokens as $token) {
$participantToken = $token->getToken();
$responseData = $tokenProvider->getResponseData($survey, $participantToken);
// Display the participant's token
echo "Token: $participantToken <br>";
// Display the question answers
foreach ($responseData as $questionId => $questionData) {
echo "Question ID: $questionId <br>";
foreach ($questionData as $subQuestionId => $answer) {
echo "Sub-Question ID: $subQuestionId <br>";
echo "Answer: $answer <br>";
}
}
echo "<br>";
}
with LimeSurvey\Survey\Repository not found error.
Please Log in to join the conversation.
- MikhailGorbunov
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 5
6 months 1 week ago - 6 months 1 week ago #251171
by MikhailGorbunov
[/code]
[/code]
PHP Fatal error: Uncaught SodiumException: sodium_crypto_secretbox_open(): Argument #2 ($nonce) must be SODIUM_CRYPTO_SECRETBOX_NONCEBYTES bytes long in
Replied by MikhailGorbunov on topic Question attribute "Encrypted" is used to enable data encryption
Code:
[code][code]while ($row=mysqli_fetch_array($result )){ sodium_crypto_secretbox_open($row['111111X1X1SQ001'],$nonce,$key) }
[/code]
Code:
with nonce and key from config.php trows
PHP Fatal error: Uncaught SodiumException: sodium_crypto_secretbox_open(): Argument #2 ($nonce) must be SODIUM_CRYPTO_SECRETBOX_NONCEBYTES bytes long in
Last edit: 6 months 1 week ago by MikhailGorbunov.
Please Log in to join the conversation.
- OpenStudio
- Offline
- New Member
Less
More
- Posts: 11
- Thank you received: 2
4 months 1 week ago #253633
by OpenStudio
Replied by OpenStudio on topic Question attribute "Encrypted" is used to enable data encryption
Did you manage to solve?
I am also having the same necessity/issue!
I am also having the same necessity/issue!
Please Log in to join the conversation.
- MikhailGorbunov
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 5
4 months 1 week ago - 4 months 1 week ago #253652
by MikhailGorbunov
No I don`t still trying.
I know uncrypted data is shown in admin menu.
You can track issue in stackoverflow.com
Replied by MikhailGorbunov on topic Question attribute "Encrypted" is used to enable data encryption
Hello.Did you manage to solve?
I am also having the same necessity/issue!
No I don`t still trying.
I know uncrypted data is shown in admin menu.
You can track issue in stackoverflow.com
Last edit: 4 months 1 week ago by MikhailGorbunov.
The following user(s) said Thank You: DenisChenu
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
4 months 1 week ago #253666
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Question attribute "Encrypted" is used to enable data encryption
Moving it to development section
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
4 months 1 week ago #253668
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Question attribute "Encrypted" is used to enable data encryption
Some code
github.com/LimeSurvey/LimeSurvey/blob/41...re/LSSodium.php#L135
Maybe need base64_decode ?
github.com/LimeSurvey/LimeSurvey/blob/41...re/LSSodium.php#L135
Maybe need base64_decode ?
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Please Log in to join the conversation.
- MikhailGorbunov
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 5
4 months 1 week ago - 4 months 1 week ago #253669
by MikhailGorbunov
But i think they encoded in Limesurvey config file and one should decrypt nonce and key before use.
Main mystery is how to decrypt nonce and key from config file to solve Argument #2 ($nonce) must be SODIUM_CRYPTO_SECRETBOX_NONCEBYTES bytes long in problem in sodium_crypto_secretbox_open() function.
Replied by MikhailGorbunov on topic Question attribute "Encrypted" is used to enable data encryption
Error in nonce or key format. You can see at line 139 they are not decoded.Some code
github.com/LimeSurvey/LimeSurvey/blob/41...re/LSSodium.php#L135
Maybe need base64_decode ?
Code:
$this->sEncryptionNonce, $this->sEncryptionSecretBoxKey
But i think they encoded in Limesurvey config file and one should decrypt nonce and key before use.
Main mystery is how to decrypt nonce and key from config file to solve Argument #2 ($nonce) must be SODIUM_CRYPTO_SECRETBOX_NONCEBYTES bytes long in problem in sodium_crypto_secretbox_open() function.
Last edit: 4 months 1 week ago by MikhailGorbunov.
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
4 months 1 week ago #253670
by DenisChenu
github.com/LimeSurvey/LimeSurvey/blob/41...ore/LSSodium.php#L64
github.com/LimeSurvey/LimeSurvey/blob/41...ore/LSSodium.php#L71
?
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Question attribute "Encrypted" is used to enable data encryption
github.com/LimeSurvey/LimeSurvey/blob/41...ore/LSSodium.php#L64
github.com/LimeSurvey/LimeSurvey/blob/41...ore/LSSodium.php#L71
?
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Please Log in to join the conversation.
- MikhailGorbunov
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 5
4 months 6 days ago - 4 months 6 days ago #253698
by MikhailGorbunov
Replied by MikhailGorbunov on topic Question attribute "Encrypted" is used to enable data encryption
Tryed sodium_hex2bin() function on them like this.
Without any error, but no decryption, clean error.log in apache, status 200 in access log, but just blank variable without data
applyed base64_decode() on
Code:
sodium_crypto_secretbox_open($row['111111X1X1SQ001'],sodium_hex2bin('nonce'),sodium_hex2bin('key'))
applyed base64_decode() on
Code:
sodium_crypto_secretbox_open() output with same effect.
Last edit: 4 months 6 days ago by MikhailGorbunov.
Please Log in to join the conversation.
- MikhailGorbunov
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
- Thank you received: 5
4 months 6 days ago #253700
by MikhailGorbunov
works fine. Feel free to use this solution on external .php data output with nonce and key from secure.php in config directory.
Replied by MikhailGorbunov on topic Question attribute "Encrypted" is used to enable data encryption
Code:
sodium_crypto_secretbox_open(base64_decode($row['111111X1X1SQ001']),sodium_hex2bin('$nonce'),sodium_hex2bin('$key'))
works fine. Feel free to use this solution on external .php data output with nonce and key from secure.php in config directory.
The following user(s) said Thank You: DenisChenu, OpenStudio
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
4 months 6 days ago #253701
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Question attribute "Encrypted" is used to enable data encryption
Great ! You got it !!
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Please Log in to join the conversation.