duankang8114 2015-10-14 09:31
浏览 1204


I want to know if there is any difference between these two encryption methods? I never used these before. My client asked me to use AES-128 encryption but when I google it, it show me "aes-128-cbc", "aes-128-ctr", "aes-256-cbc", or "aes-256-ctr" so I want to know which one I should use that will be like AES-128?

reference link : this is where I have to send encryption method

  • 写回答

4条回答 默认 最新

  • douyu7210 2015-10-14 12:00

    3 things:

    • AES: Advanced Encryption Standard. This is the name of the encryption algorithm (symmetric encryption). Other symmetric encryption algorithms are: DES, 3-DES etc.
    • 128: This probably refers to the key size. AES encryption uses 3 key sizes (128bit, 192bit and 256bit). Block size in AES is also 128 bits.
    • CBC: This is the mode of encryption that you want. There are number of modes of encryption, which depends on how fast you want your algorithm to work, parallelism and level of security. A few modes are CBC(Cipher Block Chaining), ECB(Electronic Code Book), CFB(Cipher Feed Back), CTR (Counter) etc.

    Now, your client asked you to encrypt using AES-128. So, you should be using AES encryption with 128 bit key size. Any mode you can use will be of your preference. I'd prefer CBC.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
  • douyi7283 2015-10-14 13:45

    Looking at the link you included, it says it will accept a number of different modes, including CBC. Unless you have a specific reason not to use it, then use AES-128-CBC. CBC mode is a good general-purpose mode. You will also need to understand the use of padding (use PKCS#5 or PKCS#7, whatever one your system allows) and an Initialisation Vector, IV, in order for CBC mode to work correctly.

    Do not use ECB mode, since it is insecure and leaks information.

  • dpvv37755 2015-10-14 13:59

    Just a quick note on CBC vs ECB. When you encrypt using ECB, every 128 bit (depending on the block size) of data gets encrypted with the same key. If there is any pattern in the plaintext, the resulting encrypted text will also be predictable, no matter how good the encryption algorithm is.


    Plain text: aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa
                ---------------- ---------------- ----------------
    Encrypted:  bdefjakjapqeiowp bdefjakjapqeiowp bdefjakjapqeiowp

    If you use CBC, the first block gets XOR'd with the IV (initialization vector) and encrypted with the key and the second block gets XOR'd with the first block and then encrypted with the key, the third with the second. The resulting cipher is then less vulnerable to frequency analysis. CBC Encryption mode

    This image is taken from Wikimedia Commons, the free media repository

    The disadvantage is that you cannot parallelize the encryption/decryption since you need the result of the previous block, so it may be slower. But in practice, it makes no real difference.

  • doutongxuan1614 2017-02-24 07:12

    Here aes-128-cbc and aes-128. aes stands for advanced encryption service, 128 is the bit rate, and CBC is the mode of encryption.

    However, this is recited and used only in OPEN SSL Formats. Prior to Open SSL, PHP used mcrypt_encrypt which was not properly designed (older versions of PHP). aes-128 can also be reffered to as rijndael while using mcrypt.




  • ¥15 关于#abap#的问题,请各位专家解答!
  • ¥20 内网通过公网访问外网问题
  • ¥20 谁有这个东西 继续教育的
  • ¥15 怎么使请求通过cors
  • ¥15 WDM 驱动ACPI 相关疑问
  • ¥15 prism 跨窗体共享数据绑定 wpf
  • ¥15 hdl designer突然用不了系统的moduleware组件,请问有人遇到或者怎么解决吗?
  • ¥15 0基础计算机毕设,应该从哪开始?
  • ¥60 使用DKT40脑图划分ROI区域
  • ¥15 有偿解决C51单片机液晶屏12864显示问题