Skip to content

Instantly share code, notes, and snippets.

@wilbertverayin
Last active November 4, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilbertverayin/999b97e7b03a9185c784 to your computer and use it in GitHub Desktop.
Save wilbertverayin/999b97e7b03a9185c784 to your computer and use it in GitHub Desktop.

Encryption

Common Algorithms

  • Advanced Encryption Standard
  • Blowfish
  • Data Encryption Standard
  • Triple Data Encryption Standard
  • Serpent
  • Twofish

See this article for complete list The best one is the Blowfish

Less Common Algorithms

  • Camellia
  • CAST-128
  • IDEA
  • RC2
  • RC5
  • SEED
  • ARIA
  • Skipjack
  • TEA = XTEA

Common Attacks on Encrypted data

  • Brute-force (EFF DES cracker)
  • MITM (Biclique attack, 3-subset MITM attack)
  • Linear (Piling-up lemma)
  • Differential (Impossible Truncated Higher-order)
  • Differential-linear Distinguishing (Known-key)
  • Integral/Square
  • Boomerang
  • Mod n
  • Related-key
  • Slide
  • Rotational
  • Timing
  • XSL
  • Interpolation
  • Partitioning
  • Davies'
  • Rebound
  • Weak key
  • Tau
  • Chi-square
  • Time/memory/data tradeoff

See more details on this article

Common Block Cipher Modes of Operation

  • Electronic Codebook (ECB)
  • Cipher Block Chaining (CBC)
  • Cipher Feedback (CFB)
  • Output Feedback (OFB)
  • Counter (CTR)

More information on this Wiki Article

Benchmark

Below is a speed test made on 50 000 iterations.

[
    {
        "cipher": "aes-192-ctr",
        "encrypted_string": "4d87237423d3e1bcaa8461545bd72e94f21c84",
        "encrypted_string_length": 38,
        "duration": 453
    },
    {
        "cipher": "des-ofb",
        "encrypted_string": "2a8a0dbd7898f9bb1c5e6a452b86bbd098593a",
        "encrypted_string_length": 38,
        "duration": 458
    },
    {
        "cipher": "aes-192-ofb",
        "encrypted_string": "4d87237423d3e1bcaa8461545bd72e942cfa54",
        "encrypted_string_length": 38,
        "duration": 465
    },
    {
        "cipher": "aes-128-ctr",
        "encrypted_string": "887acbaa56347e9630e42f0f15e17adeafa668",
        "encrypted_string_length": 38,
        "duration": 469
    },
    {
        "cipher": "idea-cfb",
        "encrypted_string": "67f034f5289df2ad663081df29a0929a0927e5",
        "encrypted_string_length": 38,
        "duration": 471
    },
    {
        "cipher": "aes-256-cfb",
        "encrypted_string": "97d08cda161f40d7ec78fe1854c1ce1aa652db",
        "encrypted_string_length": 38,
        "duration": 472
    },
    {
        "cipher": "idea-ofb",
        "encrypted_string": "67f034f5289df2ada09bbdd94de093b3e847ef",
        "encrypted_string_length": 38,
        "duration": 473
    },
    {
        "cipher": "aes-128-cfb",
        "encrypted_string": "887acbaa56347e9630e42f0f15e17adedc60e7",
        "encrypted_string_length": 38,
        "duration": 474
    },
    {
        "cipher": "aes-128-ofb",
        "encrypted_string": "887acbaa56347e9630e42f0f15e17ade501aa3",
        "encrypted_string_length": 38,
        "duration": 476
    },
    {
        "cipher": "seed-cfb",
        "encrypted_string": "97c112abd92cf1ac6379ba626b0165d0753bb6",
        "encrypted_string_length": 38,
        "duration": 483
    },
    {
        "cipher": "aes-192-cfb",
        "encrypted_string": "4d87237423d3e1bcaa8461545bd72e94e99af3",
        "encrypted_string_length": 38,
        "duration": 484
    },
    {
        "cipher": "rc4",
        "encrypted_string": "6148b6f38aadf413c486decbca17ef247bab9d",
        "encrypted_string_length": 38,
        "duration": 486
    },
    {
        "cipher": "des-cfb",
        "encrypted_string": "2a8a0dbd7898f9bb05fec92992caa925d226fd",
        "encrypted_string_length": 38,
        "duration": 489
    },
    {
        "cipher": "seed-ofb",
        "encrypted_string": "97c112abd92cf1ac6379ba626b0165d03f3cea",
        "encrypted_string_length": 38,
        "duration": 489
    },
    {
        "cipher": "aes-128-xts",
        "encrypted_string": "7cbfeebf08315873f02e3083230035e1ebb786",
        "encrypted_string_length": 38,
        "duration": 492
    },
    {
        "cipher": "camellia-256-ofb",
        "encrypted_string": "048c6c046492fa450a7060731f003c4e88d6f1",
        "encrypted_string_length": 38,
        "duration": 492
    },
    {
        "cipher": "rc4-hmac-md5",
        "encrypted_string": "6148b6f38aadf413c486decbca17ef247bab9d",
        "encrypted_string_length": 38,
        "duration": 496
    },
    {
        "cipher": "camellia-192-cfb",
        "encrypted_string": "94dbe4bc40c9eeff02536bd5c167cbc168ae24",
        "encrypted_string_length": 38,
        "duration": 497
    },
    {
        "cipher": "aes-256-ofb",
        "encrypted_string": "97d08cda161f40d7ec78fe1854c1ce1a8e19a1",
        "encrypted_string_length": 38,
        "duration": 500
    },
    {
        "cipher": "aes-128-cfb8",
        "encrypted_string": "88d908d357282607e31594c5f6aa12ecb325d0",
        "encrypted_string_length": 38,
        "duration": 501
    },
    {
        "cipher": "aes-192-ecb",
        "encrypted_string": "4ebefaf182b40b4c545919c370bcc62bbd7841904895dda36d561666373f978f",
        "encrypted_string_length": 64,
        "duration": 505
    },
    {
        "cipher": "camellia-256-cfb",
        "encrypted_string": "048c6c046492fa450a7060731f003c4efd378d",
        "encrypted_string_length": 38,
        "duration": 505
    },
    {
        "cipher": "aes-256-ctr",
        "encrypted_string": "97d08cda161f40d7ec78fe1854c1ce1a14f307",
        "encrypted_string_length": 38,
        "duration": 508
    },
    {
        "cipher": "cast5-ofb",
        "encrypted_string": "f61ce63f40648951b8518f21f1f6a429bfaf13",
        "encrypted_string_length": 38,
        "duration": 509
    },
    {
        "cipher": "rc4-40",
        "encrypted_string": "dc68b94f768b4a14ac60da48c1e8ebad43096f",
        "encrypted_string_length": 38,
        "duration": 509
    },
    {
        "cipher": "aes-256-xts",
        "encrypted_string": "2b8bce26603992b57fca8f86c1a64abd05b83d",
        "encrypted_string_length": 38,
        "duration": 514
    },
    {
        "cipher": "camellia-128-ofb",
        "encrypted_string": "9655246b9fd616a6eb32044b95425e7c3d0f30",
        "encrypted_string_length": 38,
        "duration": 515
    },
    {
        "cipher": "cast5-cfb",
        "encrypted_string": "f61ce63f40648951b2904e983ca791342ddb9c",
        "encrypted_string_length": 38,
        "duration": 515
    },
    {
        "cipher": "aes-192-cfb8",
        "encrypted_string": "4deb74da59a7f369d5641839ce8b85b66b1b3f",
        "encrypted_string_length": 38,
        "duration": 516
    },
    {
        "cipher": "aes-256-ecb",
        "encrypted_string": "7bd141191ada3930d8cb07b8bc36458f29a5cc851f557959571237afadb5b358",
        "encrypted_string_length": 64,
        "duration": 517
    },
    {
        "cipher": "aes-128-ecb",
        "encrypted_string": "814167df9948b7ce06ab16ef75e2cb70f93a81c9d1390651e6e2c330beaec36f",
        "encrypted_string_length": 64,
        "duration": 530
    },
    {
        "cipher": "camellia-128-cfb",
        "encrypted_string": "9655246b9fd616a6eb32044b95425e7cd1fd06",
        "encrypted_string_length": 38,
        "duration": 533
    },
    {
        "cipher": "camellia-128-ecb",
        "encrypted_string": "89c1c601c907b751b801aa173080b179d4c952467bcaa7543f6dcb89dc3e3ed5",
        "encrypted_string_length": 64,
        "duration": 533
    },
    {
        "cipher": "camellia-192-ofb",
        "encrypted_string": "94dbe4bc40c9eeff02536bd5c167cbc1f814f0",
        "encrypted_string_length": 38,
        "duration": 538
    },
    {
        "cipher": "cast5-ecb",
        "encrypted_string": "9d321836156bd494a0b22f59cd6dcd10a53006c91c16b6a9",
        "encrypted_string_length": 48,
        "duration": 538
    },
    {
        "cipher": "aes128",
        "encrypted_string": "e467dac596851ecc2ac7209fb2d061eca45eb62958c832f0078ac9cbe4590fad",
        "encrypted_string_length": 64,
        "duration": 539
    },
    {
        "cipher": "aes256",
        "encrypted_string": "93e5a4f61768f9207f5b684cb580bdcd7304eb18c03e49a8581d562b3e6e7d58",
        "encrypted_string_length": 64,
        "duration": 539
    },
    {
        "cipher": "camellia-192-ecb",
        "encrypted_string": "5e8369c833c4d2847cd33d0a91cc69cd15e4634e60e563308bb58a292449af24",
        "encrypted_string_length": 64,
        "duration": 541
    },
    {
        "cipher": "aes-128-cbc",
        "encrypted_string": "e467dac596851ecc2ac7209fb2d061eca45eb62958c832f0078ac9cbe4590fad",
        "encrypted_string_length": 64,
        "duration": 544
    },
    {
        "cipher": "aes192",
        "encrypted_string": "ab05341053e1d1d2067c5c20c603c3348fcffc4c83905a6214264b8ca09212b7",
        "encrypted_string_length": 64,
        "duration": 544
    },
    {
        "cipher": "des-ede-cfb",
        "encrypted_string": "4df60d0a4dbb5c7eab1c5c7ca154d9bf017709",
        "encrypted_string_length": 38,
        "duration": 545
    },
    {
        "cipher": "rc2-cfb",
        "encrypted_string": "3e239d03deeba9c592a5660d2ca2cfd406248d",
        "encrypted_string_length": 38,
        "duration": 545
    },
    {
        "cipher": "des-ede-ofb",
        "encrypted_string": "4df60d0a4dbb5c7e1be8a93bdd99ac34a0d60c",
        "encrypted_string_length": 38,
        "duration": 546
    },
    {
        "cipher": "aes-256-cbc",
        "encrypted_string": "93e5a4f61768f9207f5b684cb580bdcd7304eb18c03e49a8581d562b3e6e7d58",
        "encrypted_string_length": 64,
        "duration": 548
    },
    {
        "cipher": "seed-ecb",
        "encrypted_string": "32513038f1a0876e2745ca80e2aedb886bd7caf4aa85aed2c1c59cdd0bd9c315",
        "encrypted_string_length": 64,
        "duration": 548
    },
    {
        "cipher": "des-ede3-ofb",
        "encrypted_string": "d26ac608f439839c36fc5ee852606cdac3a9a2",
        "encrypted_string_length": 38,
        "duration": 550
    },
    {
        "cipher": "aes-192-cbc",
        "encrypted_string": "ab05341053e1d1d2067c5c20c603c3348fcffc4c83905a6214264b8ca09212b7",
        "encrypted_string_length": 64,
        "duration": 552
    },
    {
        "cipher": "aes-256-cbc-hmac-sha1",
        "encrypted_string": "93e5a4f61768f9207f5b684cb580bdcd7304eb18c03e49a8581d562b3e6e7d58",
        "encrypted_string_length": 64,
        "duration": 552
    },
    {
        "cipher": "desx-cbc",
        "encrypted_string": "a5ac9343ec946a451c86658301ee954efe802b71775608b2",
        "encrypted_string_length": 48,
        "duration": 552
    },
    {
        "cipher": "camellia-256-ecb",
        "encrypted_string": "2966aa9ad6506a389543df4e8e3c1c06618a4e3855815c7f6957c1010a0cdd0d",
        "encrypted_string_length": 64,
        "duration": 553
    },
    {
        "cipher": "desx",
        "encrypted_string": "a5ac9343ec946a451c86658301ee954efe802b71775608b2",
        "encrypted_string_length": 48,
        "duration": 554
    },
    {
        "cipher": "aes-256-cfb8",
        "encrypted_string": "97600d74a5e94ed1509090329b2dd2f5ffb9f6",
        "encrypted_string_length": 38,
        "duration": 555
    },
    {
        "cipher": "aes-256-cbc-hmac-sha256",
        "encrypted_string": "93e5a4f61768f9207f5b684cb580bdcd7304eb18c03e49a8581d562b3e6e7d58",
        "encrypted_string_length": 64,
        "duration": 556
    },
    {
        "cipher": "des",
        "encrypted_string": "d0b606276e6a323e926f35b74cc63ad45a761b61e209d999",
        "encrypted_string_length": 48,
        "duration": 556
    },
    {
        "cipher": "des-ede3-cfb",
        "encrypted_string": "d26ac608f439839ca62797249228e9241bb696",
        "encrypted_string_length": 38,
        "duration": 560
    },
    {
        "cipher": "seed",
        "encrypted_string": "2d2fc2067ca99d4f077acfca35c1d4822201c90f5b2051b166e6657cc513392b",
        "encrypted_string_length": 64,
        "duration": 565
    },
    {
        "cipher": "rc2-ofb",
        "encrypted_string": "3e239d03deeba9c5e4c40855af3d749d7403bb",
        "encrypted_string_length": 38,
        "duration": 567
    },
    {
        "cipher": "camellia128",
        "encrypted_string": "1c724cdb56ab2a554aa3e5bfaa2eb2d8425c45cda01eb516da955baa996f9eb0",
        "encrypted_string_length": 64,
        "duration": 570
    },
    {
        "cipher": "aes-128-cbc-hmac-sha1",
        "encrypted_string": "e467dac596851ecc2ac7209fb2d061eca45eb62958c832f0078ac9cbe4590fad",
        "encrypted_string_length": 64,
        "duration": 571
    },
    {
        "cipher": "rc2-ecb",
        "encrypted_string": "96b6e911f007d003ec53f332d7bc65739dfe51844147d5c0",
        "encrypted_string_length": 48,
        "duration": 571
    },
    {
        "cipher": "cast",
        "encrypted_string": "0443da5f76999cf723df4a76b5620cdad4db3569812fbb1d",
        "encrypted_string_length": 48,
        "duration": 575
    },
    {
        "cipher": "des-cbc",
        "encrypted_string": "d0b606276e6a323e926f35b74cc63ad45a761b61e209d999",
        "encrypted_string_length": 48,
        "duration": 576
    },
    {
        "cipher": "camellia-256-cbc",
        "encrypted_string": "53d8c4a56527340639aad64491a719a0cc4fed011b32c680b0fb4a76cc0f554d",
        "encrypted_string_length": 64,
        "duration": 577
    },
    {
        "cipher": "cast5-cbc",
        "encrypted_string": "0443da5f76999cf723df4a76b5620cdad4db3569812fbb1d",
        "encrypted_string_length": 48,
        "duration": 578
    },
    {
        "cipher": "seed-cbc",
        "encrypted_string": "2d2fc2067ca99d4f077acfca35c1d4822201c90f5b2051b166e6657cc513392b",
        "encrypted_string_length": 64,
        "duration": 578
    },
    {
        "cipher": "cast-cbc",
        "encrypted_string": "0443da5f76999cf723df4a76b5620cdad4db3569812fbb1d",
        "encrypted_string_length": 48,
        "duration": 579
    },
    {
        "cipher": "aes-128-cbc-hmac-sha256",
        "encrypted_string": "e467dac596851ecc2ac7209fb2d061eca45eb62958c832f0078ac9cbe4590fad",
        "encrypted_string_length": 64,
        "duration": 583
    },
    {
        "cipher": "camellia-192-cbc",
        "encrypted_string": "2302537a09687d64506310d595e5a4f7176275089f1fa3b368ba16ef0908c4a6",
        "encrypted_string_length": 64,
        "duration": 583
    },
    {
        "cipher": "des-ecb",
        "encrypted_string": "fb306331083e116051d37e178622a7becaabe7ebd0d9208c",
        "encrypted_string_length": 48,
        "duration": 587
    },
    {
        "cipher": "camellia256",
        "encrypted_string": "53d8c4a56527340639aad64491a719a0cc4fed011b32c680b0fb4a76cc0f554d",
        "encrypted_string_length": 64,
        "duration": 593
    },
    {
        "cipher": "camellia192",
        "encrypted_string": "2302537a09687d64506310d595e5a4f7176275089f1fa3b368ba16ef0908c4a6",
        "encrypted_string_length": 64,
        "duration": 600
    },
    {
        "cipher": "idea",
        "encrypted_string": "caf3fc432643a66c4d48e4d6e39651277bf44d879f0c2433",
        "encrypted_string_length": 48,
        "duration": 600
    },
    {
        "cipher": "idea-cbc",
        "encrypted_string": "caf3fc432643a66c4d48e4d6e39651277bf44d879f0c2433",
        "encrypted_string_length": 48,
        "duration": 601
    },
    {
        "cipher": "rc2-64-cbc",
        "encrypted_string": "aad7d56a4a8930e0174bacef7e801d3e09ab56a84ecbfca9",
        "encrypted_string_length": 48,
        "duration": 604
    },
    {
        "cipher": "idea-ecb",
        "encrypted_string": "58b53da4850b9eae75ca656545a4c8a108ea809d8a5d973f",
        "encrypted_string_length": 48,
        "duration": 607
    },
    {
        "cipher": "rc2-cbc",
        "encrypted_string": "93985f38b81169d6419793a45ada37b6328a485bf69a3dc4",
        "encrypted_string_length": 48,
        "duration": 610
    },
    {
        "cipher": "CAST-cbc",
        "encrypted_string": "0443da5f76999cf723df4a76b5620cdad4db3569812fbb1d",
        "encrypted_string_length": 48,
        "duration": 614
    },
    {
        "cipher": "des-ede-cbc",
        "encrypted_string": "1c6ecb658eb3ca24c723d0a2748cf82e2760504ca704b890",
        "encrypted_string_length": 48,
        "duration": 615
    },
    {
        "cipher": "rc2-40-cbc",
        "encrypted_string": "ff62f254b945504d0b9742932937b034cea7f9ac7e73a840",
        "encrypted_string_length": 48,
        "duration": 625
    },
    {
        "cipher": "des-ede3",
        "encrypted_string": "1bcbb571e369accd66f3823a8680e864c836d9fe2401652f",
        "encrypted_string_length": 48,
        "duration": 626
    },
    {
        "cipher": "des-ede3-cbc",
        "encrypted_string": "6c8b92713775189a9c933f710c75aabc91f1101edb1bf8d1",
        "encrypted_string_length": 48,
        "duration": 629
    },
    {
        "cipher": "rc2",
        "encrypted_string": "93985f38b81169d6419793a45ada37b6328a485bf69a3dc4",
        "encrypted_string_length": 48,
        "duration": 647
    },
    {
        "cipher": "des3",
        "encrypted_string": "6c8b92713775189a9c933f710c75aabc91f1101edb1bf8d1",
        "encrypted_string_length": 48,
        "duration": 650
    },
    {
        "cipher": "camellia-128-cbc",
        "encrypted_string": "1c724cdb56ab2a554aa3e5bfaa2eb2d8425c45cda01eb516da955baa996f9eb0",
        "encrypted_string_length": 64,
        "duration": 666
    },
    {
        "cipher": "camellia-128-cfb8",
        "encrypted_string": "968cb8e0fe2f46a5306d168adb4ad2f7c71e1b",
        "encrypted_string_length": 38,
        "duration": 668
    },
    {
        "cipher": "camellia-192-cfb8",
        "encrypted_string": "94aa2e669d26e3dfd7346ae1bc01464ec4686d",
        "encrypted_string_length": 38,
        "duration": 675
    },
    {
        "cipher": "des-ede",
        "encrypted_string": "91224a539f2dc825b0b8c2c08c558963e7333b67f016e904",
        "encrypted_string_length": 48,
        "duration": 685
    },
    {
        "cipher": "camellia-256-cfb8",
        "encrypted_string": "0478cb675ba60c706962710feeff2e6c0e7a07",
        "encrypted_string_length": 38,
        "duration": 719
    },
    {
        "cipher": "des-cfb8",
        "encrypted_string": "2adcbcacd4199df00824c99eb2935eb0db3b02",
        "encrypted_string_length": 38,
        "duration": 724
    },
    {
        "cipher": "aes-128-cfb1",
        "encrypted_string": "f1a5197bdb3df4f81e84fe0d2792aad087c50f",
        "encrypted_string_length": 38,
        "duration": 947
    },
    {
        "cipher": "des-ede3-cfb8",
        "encrypted_string": "d27c979338745e7769c7170ad9006cf6958a5c",
        "encrypted_string_length": 38,
        "duration": 982
    },
    {
        "cipher": "aes-192-cfb1",
        "encrypted_string": "12bc6e5cb5578b8a2767e3ac866cafed13f868",
        "encrypted_string_length": 38,
        "duration": 1004
    },
    {
        "cipher": "des-ede3-cfb1",
        "encrypted_string": "93672d655f6d61696c40676d61696c2e636f6d",
        "encrypted_string_length": 38,
        "duration": 1008
    },
    {
        "cipher": "aes-256-cfb1",
        "encrypted_string": "ac3c6d55d8118f2c4249f21862bfdf22eb9e92",
        "encrypted_string_length": 38,
        "duration": 1066
    },
    {
        "cipher": "camellia-128-cfb1",
        "encrypted_string": "de8c10d55860de3c1193215bf70c256a5258c5",
        "encrypted_string_length": 38,
        "duration": 1885
    },
    {
        "cipher": "des-cfb1",
        "encrypted_string": "36c5c095ea0c9044af920a30272da01eec0c7c",
        "encrypted_string_length": 38,
        "duration": 2194
    },
    {
        "cipher": "camellia-256-cfb1",
        "encrypted_string": "445d48e9be117a33ee97104ae6bfb975c3345d",
        "encrypted_string_length": 38,
        "duration": 2237
    },
    {
        "cipher": "camellia-192-cfb1",
        "encrypted_string": "fb35d128977584cbc32340ceae46b3172f236f",
        "encrypted_string_length": 38,
        "duration": 2244
    },
    {
        "cipher": "bf-cfb",
        "encrypted_string": "e0b791c3cd1915f35d234c4007be8baca0567c",
        "encrypted_string_length": 38,
        "duration": 3422
    },
    {
        "cipher": "bf-ofb",
        "encrypted_string": "e0b791c3cd1915f3f68c38a7b02f05bc880a14",
        "encrypted_string_length": 38,
        "duration": 3470
    },
    {
        "cipher": "bf-ecb",
        "encrypted_string": "8f9812a5b036e2ebcd9aa130a8047e18671879e772321de3",
        "encrypted_string_length": 48,
        "duration": 3481
    },
    {
        "cipher": "bf-cbc",
        "encrypted_string": "568f3f1b6b7d9bdaff1553cfdd45bcfc11b6c0b06666f594",
        "encrypted_string_length": 48,
        "duration": 3486
    },
    {
        "cipher": "bf",
        "encrypted_string": "568f3f1b6b7d9bdaff1553cfdd45bcfc11b6c0b06666f594",
        "encrypted_string_length": 48,
        "duration": 3589
    },
    {
        "cipher": "blowfish",
        "encrypted_string": "568f3f1b6b7d9bdaff1553cfdd45bcfc11b6c0b06666f594",
        "encrypted_string_length": 48,
        "duration": 3609
    }
]

Conclusion

Blowfish uses more complicated algorithm, thus it is more secure. It runs a longer than other ciphers but we should proiritize data security. Also a Wiki Article stated that:

Blowfish's slow key changing is actually a benefit: the password-hashing method used in OpenBSD uses an algorithm derived from Blowfish that makes use of the slow key schedule; the idea is that the extra computational effort required gives protection against dictionary attacks.

As prescribed by this formal paper, Blowfish is the best choice.

More Details

More details on cryptography

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment