Code Monkey home page Code Monkey logo

cryptography-2's Introduction

About

I've put in place the CBC and CTR modes of operation for block cipher encryption and decoding. I encrypted and decrypted every 16-byte block using AES. The ciphertext is prepended with the randomly selected 16-byte encryption IV. The PKCS#5/#7 padding method is employed for CBC. Take note that a distinct ciphertext is produced for each encryption of the same message using the same key. The same communication can be decrypted from several ciphertexts.

Dependency

Sample Usage

$ python script.py

-------------
BLOCK CIPHER MODE OF OPERATION
-------------
Enter preferred mode of operation [cbc/ctr]: ctr
Enter hex-encoded key: 36f18357be4dbd77f050515c73fcf9f2
Decrypt or encrypt?[d/e]: d
Enter hex-encoded cipher to decrypt: 69dda8455c7dd4254bf353b773304eec0ec7702330098ce7f7520d1cbbb20fc388d1b0adb5054dbd7370849dbf0b88d393f252e764f1f5f7ad97ef79d59ce29f5f51eeca32eabedd9afa9329

Decrypted message:
CTR mode lets you build a stream cipher from a block cipher.

Press any key to exit.

Theory

01
02 02
03 03 03
04 04 04 04
05 05 05 05 05
06 06 06 06 06 06
etc.

CBC

Properties

Encryption parallelizable:  No
Decryption parallelizable:  Yes
Random read access: Yes

CTR

Properties

Encryption parallelizable:  Yes
Decryption parallelizable:  Yes
Random read access: Yes

Test Cases

CBC

  • Key: 140b41b22a29beb4061bda66b6747e14

Cipher A

  • The following cipher decrypts to Basic CBC mode encryption needs padding. when the key above is used
4ca00ff4c898d61e1edbf1800618fb28
28a226d160dad07883d04e008a7897ee
2e4b7465d5290d0c0e6c6822236e1daa
fb94ffe0c5da05d9476be028ad7c1d81

Cipher B

  • The following cipher decrypts to Our implementation uses rand. IV when the key above is used.
5b68629feb8606f9a6667670b75b38a5
b4832d0f26e1ab7da33249de7d4afc48
e713ac646ace36e872ad5fb8a512428a
6e21364b0c374df45503473c5242a253

CTR

  • Key: 36f18357be4dbd77f050515c73fcf9f2

Cipher C

  • The following cipher decrypts to CTR mode lets you build a stream cipher from a block cipher. when the key above is used.
69dda8455c7dd4254bf353b773304eec
0ec7702330098ce7f7520d1cbbb20fc3
88d1b0adb5054dbd7370849dbf0b88d3
93f252e764f1f5f7ad97ef79d59ce29f
5f51eeca32eabedd9afa9329

Cipher D

  • The following cipher decrypts to Always avoid the two time pad! when the key above is used.
770b80259ec33beb2561358a9f2dc617
e46218c0a53cbeca695ae45faa8952aa
0e311bde9d4e01726d3184c34451

cryptography-2's People

Contributors

cungaminoan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.