Question

create a unique cryptography program with a unique or modified hash functions.

create a unique cryptography program with a unique or modified hash functions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

This is an encryption example of PyCrypto. An example of this is the Paramiko SSH module for python, which uses PyCrypto as a dependency to encrypt information. PyCrypto is very simple, yet extremely powerful and useful for encryption within the Python programming language. Knowledge of the basics of encryption is also very useful. Run this program in Python 2.7 version but in 3.0 or higher version.

from Crypto.Cipher import AES
#base64 is used for encoding. dont confuse encoding with encryption#
#encryption is used for disguising data
#encoding is used for putting data in a specific format
import base64
# os is for urandom, which is an accepted producer of randomness that
# is suitable for cryptology.
import os
def encryption(privateInfo):
        #32 bytes = 256 bits
        #16 = 128 bits
        # the block size for cipher obj, can be 16 24 or 32. 16 matches 128 bit.
        BLOCK_SIZE = 16
        # the character used for padding
        # used to ensure that your value is always a multiple of BLOCK_SIZE
        PADDING = '{'
        # function to pad the functions. Lambda
        # is used for abstraction of functions.
        # basically, its a function, and you define it, followed by the param
        # followed by a colon,
        # ex = lambda x: x+5
        pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * PADDING
        # encrypt with AES, encode with base64
        EncodeAES = lambda c, s: base64.b64encode(c.encrypt(pad(s)))
        # generate a randomized secret key with urandom
        secret = os.urandom(BLOCK_SIZE)
        print 'encryption key:',secret
        # creates the cipher obj using the key
        cipher = AES.new(secret)
        # encodes you private info!
        encoded = EncodeAES(cipher, privateInfo)
        print 'Encrypted string:', encoded

Decryption Example:

from Crypto.Cipher import AES
import base64
import os
def decryption(encryptedString):
        PADDING = '{'
        DecodeAES = lambda c, e: c.decrypt(base64.b64decode(e)).rstrip(PADDING)
        #Key is FROM the printout of 'secret' in encryption
        #below is the encryption.
        encryption = encryptedString
        key = ''
        cipher = AES.new(key)
        decoded = DecodeAES(cipher, encryption)
        print decoded

Note:

  • You must run on Python 2.7.
  • You need to download the modules to run the program.
  • I have given the program for encryption and decryption also.

Hope you understand, Thank You!

Add a comment
Know the answer?
Add Answer to:
create a unique cryptography program with a unique or modified hash functions.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please complete the following task: Create a C++ hash table program for generating a hash from a string. Create a hash f...

    Please complete the following task: Create a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...

  • Topic: Intro to Cryptography Collision-resistant hash function Let (Gen1, H1) and (Gen2, H2) be two hash...

    Topic: Intro to Cryptography Collision-resistant hash function Let (Gen1, H1) and (Gen2, H2) be two hash functions, where at least one of them is collision resistant. Define (Gen, H) in the following. Prove or disprove that (Gen, H) is necessarily collision resistant. (a) Gen runs Gen, and Gen, to obtain keys 81 and 82, respectively. Then define H$1,82 (2) := H (2)| HP (). (b) Gen runs Gen, and Gen, to obtain keys and s2, respectively. Then define H81,82 ()...

  • I really need assistance with creating a C++ hash table program for generating a hash from a string. Create a hash funct...

    I really need assistance with creating a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...

  • I really need assistance with creating a C++ hash table program for generating a hash from a string. Create a hash funct...

    I really need assistance with creating a C++ hash table program for generating a hash from a string. Create a hash function then test and evaluate the results. The set of strings are from a "words.txt" file (there are 45,402 words in the file, no repeating words. Map the words to 45,402 buckets using a hash function). Requirements: Create an array of 45,402 integers and initialize each to zero. These will be used to store how many times each index...

  • C code: hash program (use the Fowler-Noll-Vo (FNV) hash algorithm) This is a simple program that...

    C code: hash program (use the Fowler-Noll-Vo (FNV) hash algorithm) This is a simple program that you will use in the second part of the assignment. Details of this program is as follows. A hashing algorithm is simply an algorithm that maps data of an arbitrary size into a hash value of a fixed size. On your VM, you should have a program called ”md5sum”, which computes the MD5 hash of a file (or bytes taken from standard input). One...

  • State whether or not the following hash functions are good or bad hash functions for storing...

    State whether or not the following hash functions are good or bad hash functions for storing fractions. Note that an equals method is provided which considers unsimplified fractions to be equal (4/2 = 2/1 ... etc) 1) the hash function is (numerator * 17) / gcd of the numerator and the denominator 2) the hash function is (numerator + denominator * 17) / gcd of numerator and denominator 3) the hash function is (numerator * 17) / denominator

  • Create a program that determines and displays the number of unique characters in a string entered...

    Create a program that determines and displays the number of unique characters in a string entered by the user. For example, Hello NITS Students! has 15 unique characters, while zzzz has only one unique character. python only with instructions

  • Develop a java program that creates Hash Table, with collision resolution either by “Separate Chaining” or...

    Develop a java program that creates Hash Table, with collision resolution either by “Separate Chaining” or “Open Addressing” (aka “Probing”).Then reads a text file into the Hash table. The program should be able to do a search for inserted data and be modified to keep track of actual clock time for a given run, as well as counting the number of operations required. The track-worthy operations will likely include character and/or full-key comparisons.

  • PROGRAM DESCRIPTION Implement a hash table class. Your hash table should resolve collisions by chaining and...

    PROGRAM DESCRIPTION Implement a hash table class. Your hash table should resolve collisions by chaining and use the multiplication method to generate hash keys. You may use your own linked list code from a previous assignment or you can use a standard sequence container. Partial definitions for the hash table class and a generic data class are provided (C++ and Java versions). You may use them as a starting point if you wish. If you choose to design your own...

  • Chapter 06 Applied Cryptography 1. How is integrity provided? A. Using two-way hash functions and digital...

    Chapter 06 Applied Cryptography 1. How is integrity provided? A. Using two-way hash functions and digital signatures B. Using one-way hash functions and digital signatures C. By applying a digital certificate D. By using asymmetric encryption 2. Which term refers to the matching of a user to an account through previously shared credentials? A. Nonrepudiation B. Digital signing C. Authentication D. Obfuscation 3. Which term refers to an arranged group of algorithms? A. Crypto modules B. Cryptographic service providers (CSPs)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT