-1

I am doing a project on IT security, my project involves data encryption and decryption. I have an idea of generating a truly random key which cannot be re-used using a one-time-pad. But i would not like to start from the scratch in writing the code since i am not an expert in the python programming language. I need the code which is written in python. As well as the code should be executable on windows OS. since i am using windows 7 and 8.

3 Answers3

2

A true One-Time-Pad is impractical for your purpose. The key cannot be recreated at the receiving end, but must be transmitted to the receiver. Since the key is as long as the message, and must be kept secure, then you must already have a secure way to transmit something of the same length. So ignore the key and just securely transmit the message.

99% of all "improved" OTPs turn out to be stream ciphers. I suspect that your design is no different. Research stream ciphers for ideas.

rossum
  • 15,344
  • 1
  • 24
  • 38
  • I suspect the point of the assignment is to use a OTP with pre-shared, secure OTPs. But have a cookie anyway. – msw Jul 11 '15 at 03:42
1

You cannot generate cryptographically good randomness from a Pseudo-Random Number Generator, which is almost every computer based RNG.

In Python, you can use random.SystemRandom if your system provides the service, and it will take longer than your patience because the system takes a while to gather entropy.

For a class exercise, a OTP of 0x00000000… or 0x01020304… might be perfect for demonstration purposes. It might even be better because by-hand verification is much easier.

Indeed, an OTP of all zeros, as Randall Munroe shows is a perfectly random OTP

msw
  • 42,753
  • 9
  • 87
  • 112
-1

A truly random key is impractical and impossible to generate. What you need is a cryptographically random key. In python this can be generated by os.urandom(n) which is used by random.SystemRandom as user msw suggested.

Although creating your own random function would be the best, this should suffice.

Shreyas Chavan
  • 1,079
  • 1
  • 7
  • 17
  • 1
    `creating your own random function would be the best` :o `truly random ... is ... impossible` :o . No and No. – deviantfan Jul 11 '15 at 01:43