AES 256 character length
I am encrypting data using AES 256 encryption, want to know how can i restrict length of the encrypted text. if i encrypt 6 character string using AES 256 it gets encrypted around 100 character. I want to add this data in table so wanted to know the maximum length so that i can set constraint in table in php codeigniter.
$this->encryption->initialize(
array(
'cipher' => 'aes-256',
'mode' => 'ECB',
'key' => $key1
)
);
$this->encryption->encrypt($_POST['uname']);
php mysql codeigniter
add a comment |
I am encrypting data using AES 256 encryption, want to know how can i restrict length of the encrypted text. if i encrypt 6 character string using AES 256 it gets encrypted around 100 character. I want to add this data in table so wanted to know the maximum length so that i can set constraint in table in php codeigniter.
$this->encryption->initialize(
array(
'cipher' => 'aes-256',
'mode' => 'ECB',
'key' => $key1
)
);
$this->encryption->encrypt($_POST['uname']);
php mysql codeigniter
add a comment |
I am encrypting data using AES 256 encryption, want to know how can i restrict length of the encrypted text. if i encrypt 6 character string using AES 256 it gets encrypted around 100 character. I want to add this data in table so wanted to know the maximum length so that i can set constraint in table in php codeigniter.
$this->encryption->initialize(
array(
'cipher' => 'aes-256',
'mode' => 'ECB',
'key' => $key1
)
);
$this->encryption->encrypt($_POST['uname']);
php mysql codeigniter
I am encrypting data using AES 256 encryption, want to know how can i restrict length of the encrypted text. if i encrypt 6 character string using AES 256 it gets encrypted around 100 character. I want to add this data in table so wanted to know the maximum length so that i can set constraint in table in php codeigniter.
$this->encryption->initialize(
array(
'cipher' => 'aes-256',
'mode' => 'ECB',
'key' => $key1
)
);
$this->encryption->encrypt($_POST['uname']);
php mysql codeigniter
php mysql codeigniter
edited Nov 12 '18 at 17:17
RiggsFolly
69.8k1864109
69.8k1864109
asked Nov 12 '18 at 17:16
Shaikh Azhar Alam
90213
90213
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Best guess given minimal information is that you are treating encrypted data as a null terminated character string and since the encryption does not null terminate the encrypted data the null terminator is something that just happens to be in memory falling the encrypted data.
The following assume AES in ECB mode.
- AES does not encrypt characters, it encrypts data bytes. If you are trying to handle the encrypted output as characters that is incorrect and will generally produce errors. It character output is required the encrypted data needs to be encoded, generally with Base64 or hexadecimal.
- AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.
- If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.
- Data encrypted with AES will be at most one block length larger than the input due to padding.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267054%2faes-256-character-length%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Best guess given minimal information is that you are treating encrypted data as a null terminated character string and since the encryption does not null terminate the encrypted data the null terminator is something that just happens to be in memory falling the encrypted data.
The following assume AES in ECB mode.
- AES does not encrypt characters, it encrypts data bytes. If you are trying to handle the encrypted output as characters that is incorrect and will generally produce errors. It character output is required the encrypted data needs to be encoded, generally with Base64 or hexadecimal.
- AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.
- If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.
- Data encrypted with AES will be at most one block length larger than the input due to padding.
add a comment |
Best guess given minimal information is that you are treating encrypted data as a null terminated character string and since the encryption does not null terminate the encrypted data the null terminator is something that just happens to be in memory falling the encrypted data.
The following assume AES in ECB mode.
- AES does not encrypt characters, it encrypts data bytes. If you are trying to handle the encrypted output as characters that is incorrect and will generally produce errors. It character output is required the encrypted data needs to be encoded, generally with Base64 or hexadecimal.
- AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.
- If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.
- Data encrypted with AES will be at most one block length larger than the input due to padding.
add a comment |
Best guess given minimal information is that you are treating encrypted data as a null terminated character string and since the encryption does not null terminate the encrypted data the null terminator is something that just happens to be in memory falling the encrypted data.
The following assume AES in ECB mode.
- AES does not encrypt characters, it encrypts data bytes. If you are trying to handle the encrypted output as characters that is incorrect and will generally produce errors. It character output is required the encrypted data needs to be encoded, generally with Base64 or hexadecimal.
- AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.
- If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.
- Data encrypted with AES will be at most one block length larger than the input due to padding.
Best guess given minimal information is that you are treating encrypted data as a null terminated character string and since the encryption does not null terminate the encrypted data the null terminator is something that just happens to be in memory falling the encrypted data.
The following assume AES in ECB mode.
- AES does not encrypt characters, it encrypts data bytes. If you are trying to handle the encrypted output as characters that is incorrect and will generally produce errors. It character output is required the encrypted data needs to be encoded, generally with Base64 or hexadecimal.
- AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.
- If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.
- Data encrypted with AES will be at most one block length larger than the input due to padding.
edited Nov 12 '18 at 17:50
answered Nov 12 '18 at 17:45
zaph
97.7k18150193
97.7k18150193
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267054%2faes-256-character-length%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown