简体   繁体   中英

TripleDESCryptoServiceProvider.Blocksize different from PHP's mcrypt_get_key_size

why does (C#)

System.Security.Cryptography.TripleDESCryptoServiceProvider.BlockSize

and (PHP)

mcrypt_get_block_size(MCRYPT_TIPRLEDES, MCRYPT_MODE_ECB);

returns a different result?

The C# System.Security.Cryptography.TripleDESCryptoServiceProvider.BlockSize value is in bits , while PHP's mcrypt_get_block_size() returns it in bytes .

1 byte = 8 bits; 64 / 8 = 8 bytes

It's the same value, just represented in different measurement units.

  1. Encryption key sizes and block sizes are not related.

  2. DES and thus Triple DES have a block size of 8-bytes.

  3. Triple DES has a key size of 168-bits in 24-bytes. There are schemes to use shorter keys such as 16-bytes and duplicate the first 8-bytes to the last 8-bytes, this sometimes called Two Key Triple DES.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM