AES 256 character length












1














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']);









share|improve this question





























    1














    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']);









    share|improve this question



























      1












      1








      1







      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']);









      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 17:17









      RiggsFolly

      69.8k1864109




      69.8k1864109










      asked Nov 12 '18 at 17:16









      Shaikh Azhar Alam

      90213




      90213
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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.




          1. 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.

          2. AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.

          3. If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.

          4. Data encrypted with AES will be at most one block length larger than the input due to padding.






          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            1














            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.




            1. 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.

            2. AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.

            3. If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.

            4. Data encrypted with AES will be at most one block length larger than the input due to padding.






            share|improve this answer




























              1














              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.




              1. 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.

              2. AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.

              3. If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.

              4. Data encrypted with AES will be at most one block length larger than the input due to padding.






              share|improve this answer


























                1












                1








                1






                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.




                1. 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.

                2. AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.

                3. If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.

                4. Data encrypted with AES will be at most one block length larger than the input due to padding.






                share|improve this answer














                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.




                1. 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.

                2. AES is a block cipher and as such the output will always be a multiple of the block length, 16-bytes for AES.

                3. If the input is not an exact multiple of the block size it needs to e padded, PKCS#7 is the generally used padding.

                4. Data encrypted with AES will be at most one block length larger than the input due to padding.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 12 '18 at 17:50

























                answered Nov 12 '18 at 17:45









                zaph

                97.7k18150193




                97.7k18150193






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Error while running script in elastic search , gateway timeout

                    Adding quotations to stringified JSON object values