SunQuest
           Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old April 21st, 2003, 01:55 AM
TheBlackMamba TheBlackMamba is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 25 TheBlackMamba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to TheBlackMamba Send a message via Yahoo to TheBlackMamba
Question Encryption

Does anyone know of an encryption function/script for Python?

Reply With Quote
  #2  
Old April 21st, 2003, 10:56 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
md5

Python is great for encyption and the md5 module makes it so easy! You can use the md5 like this:

import md5
md5.new('hey').digest()

or

import md5
m = md5.new()
m.update("hey")
m.digest()

md5 is definatly my favourate way of ecryping data although there are several ways do do it.

Mark

Last edited by netytan : April 21st, 2003 at 11:05 AM.

Reply With Quote
  #3  
Old April 21st, 2003, 12:13 PM
TheBlackMamba TheBlackMamba is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 25 TheBlackMamba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to TheBlackMamba Send a message via Yahoo to TheBlackMamba
This isn't quite what I was looking for. Let me be more specific. I'm looking for a script/module/function in python that works something like this:

(pseudo-code)
import encryptx
a = "text to be encrypted"
b = "password/key"
c = encryptx(a, b)
# a has been encrypted as c with b as the password/key

d = decryptx(c, b)
#c has been decrypted as d with b as the password/key

Reply With Quote
  #4  
Old April 21st, 2003, 12:40 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
crypt

If your using Unix (and Linux?) you can use the crypt() function, have a look at the Python documentation.

What are you trying to do exactly, It sounds like some kind of login script? I wrote a CGI login script in Python a little while ago if this is what your doing I could give you an example. It uses md5 but it does the job!!!

Mark.

Reply With Quote
  #5  
Old April 21st, 2003, 01:29 PM
TheBlackMamba TheBlackMamba is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 25 TheBlackMamba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to TheBlackMamba Send a message via Yahoo to TheBlackMamba
I am trying to create an encrypted journal, and I'm looking for a cross-platform solution. I did find one solution, ezPyCrypto, but it refuses to install.

Reply With Quote
  #6  
Old April 21st, 2003, 07:24 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
mmm

Ah, that could be a slight prob. Why not write you own? I mean, its not that hard.. you can create a basic encryption by using translate, change a for be or something similar and then you could decrypt it easily. also if you use several layers of translation that would make it more secure, and by distributing only the .pyc file only you will have the key (if your going to distribute that is).

Is it for personal use or a production project?

Sos, can't really help you there, I'll look into it and if I do think of anything else I'll definatly let you know.

Mark

Reply With Quote
  #7  
Old April 21st, 2003, 11:32 PM
TheBlackMamba TheBlackMamba is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 25 TheBlackMamba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to TheBlackMamba Send a message via Yahoo to TheBlackMamba
Python Cryptography Toolkit

After a little searching I found the Python Cryptography Toolkit (http://www.amk.ca/python/code/crypto.html)
After a few hours of trial and error and learning I figured it out and have developed a solution that fits my needs. I send the text through ROT13, then XOR, and finally I generate a SHA fingerprint to check the file against when it is decrypted. The toolkit is great and it can be mastered in about a day. It's quite powerful and contains many ciphers. I highly recommend it to anyone who needs to use encryption in Python.

PYTHON ROCKS!

Reply With Quote
  #8  
Old May 3rd, 2003, 03:59 PM
HiFidelity HiFidelity is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: UK
Posts: 13 HiFidelity User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi BlackMamba, I've been planning on doing the same thing (a passworded journal) for a while and I'm sure there must be plenty of people who'd find a utility like that handy.
My thought was to make the journal (and the encryption) a command line utility and then add an aqua interface to it.

Will you be keeping this project to yourself or will you consider opening it up and sharing the source code and/or work load?

Reply With Quote
  #9  
Old May 4th, 2003, 11:21 AM
TheBlackMamba TheBlackMamba is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 25 TheBlackMamba User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to TheBlackMamba Send a message via Yahoo to TheBlackMamba
Opening the code

I'd be happy to open the code to my program. If you or any1 else is interested, drop me a line at:
krebert at mindspring.com

So far, the code includes a couple encryption and hashing functions, and a basic text interface.

Reply With Quote
  #10  
Old October 3rd, 2003, 04:18 PM
Andy Kanyer Andy Kanyer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 Andy Kanyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Andy Kanyer
When using the md5 module... how do you decrypt the digest?

also... is it possible to simply write the digest to file and read it in later and decrypt it?

thanks

Reply With Quote
  #11  
Old October 3rd, 2003, 06:38 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Unfortunatly md5 is a one way encryption, so you wont be able to decrypt your digest sorry . You can store it as you would any other string, and read it in for comparisons i.e. a passwords

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #12  
Old October 3rd, 2003, 06:41 PM
Andy Kanyer Andy Kanyer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 Andy Kanyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Andy Kanyer
oh i get it, you can never decrypt it, but you can compare the digest to another to test for equality?

that could be very very usefull

thanks

Reply With Quote
  #13  
Old October 3rd, 2003, 07:46 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
You got it, comparison but not decryption

Mark.

Reply With Quote
  #14  
Old October 6th, 2003, 08:52 AM
whitelines's Avatar
whitelines whitelines is offline
action=(isSleep())?sleep:code;
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Sydney->Indiana
Posts: 182 whitelines User rank is Corporal (100 - 500 Reputation Level)whitelines User rank is Corporal (100 - 500 Reputation Level)whitelines User rank is Corporal (100 - 500 Reputation Level)whitelines User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 15 h 8 m 29 sec
Reputation Power: 9
Ahh, I hope this isn't very secure stuff, I mean ROT13 and XOR do not exactly stand up to even the most basic cryptanalysis.
The whole thing could be bruteforced in max a couple of minutes on a regular pentium III. If you want strong encryption use something like blowfish, Java has some awesome libraries, specifically the javax.crypto library with good examples too.

Just a note, MD5 is not encryption, it's a cryptographically secure hash. As said it's one way, it's a fingerprint of the data, the whole point is it's incredibly difficult (read impossible) to reconstruct the data which generated the hash. Remember that anyone can do MD5, which means anyone can generate a valid MD5 hash for a given piece of data, it's not tied to a key.

Cheers,
Benjamin
__________________
/*
* www.benjaminranck.com
* bjamins.blogspot.com
*/

Reply With Quote
  #15  
Old October 6th, 2003, 10:22 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Whitelines, nearly any encrpytion can be bruitforced pretty easily, if you have the capability to generate that encryption in the first place and a large enough dictionary! Which is why we pick passwords carefully