I wasn't going to pursue this any further. Actually, I am quite
disappointed about the belligerent style of some correspondents. It's not
necessary. It spoils the fun. It cloggs bandwidth.
Why whack someone over the head who tries to develop an idea of his own.
Such an approach isn't uncommon to earn extra credit in educational
settings.
True, I have also been offered good advice and being able to extract it
from between insuslts I have expressed my appreciation for it. In return of
the favor I offer a little anecdote about the nature of creativeness.
The connection between candor and creativeness has always fascinated me.
At some point, almost thirty years ago, I came across an article in a hang
glider magazine by one Dr. Paul MacCready who had just won the Kremer Prize
with his human-powered Gossamer Condor, a prize that had been standing for
decades despite innumerable unsuccessful attempts to win it. In that
article MacCready explained that it was the advent of hang gliders that
gave him the idea to go for the Kremer prize. Namely, he immediately
realized that hang gliders dissipated less energy in stable flight than any
other aircraft in existence, not because the flew so well--they didn't--but
because of their low weight. He calculated that a twenty-kilogram hang
glider with a wing span of close to thirty meters would dissipate no more
than one third of a horse power or thereabout and that is an amount of
energy a competition cyclist generates over the course of a race.
After winning the prize, MacCready challenged himself to fly across the
English channel and started building an improved second version of his
airplane. Passing through Los Angeles I went to see the project in a Long
Beach hangar and took the opportunity to pick MacCready's brain for the
benefit of our own magazine. Referring to his article I confessed my
surprise that a scientist of his caliber would be inspried by such crude
aeronautical engineering hacks as hang gliders unquestionably were. His
reply was this:
"I also consider myself an amateur. I have a PhD in aeronautics, but
not in aeronautical engineering. But this just might have been my
advantage. All these many previous failed attempts had been made by people
with better engineering credentials. If their conception of possible
solutions was better defined, it was probably also more constrained by
their knowledge of what an airplane is supposed to be."
We went on talking about creativeness and MacCready's conclusion still
rings in my ears: "Our education system encourages us to be critical. This
is a great pity. It reinforces our habit to focus on other people's
weaknesses and failures, when we could learn from observing their
strengths."
Frederic
(Robert Kern could have embarrassed me with a plain-text attack, although
his bounty wouldn't have been my credit card details. I tought about
plain-text attacks and found that in addition to changing the values of
bytes I also needed to shuffle them a little. So I added a few lines,
encoded my credit card details and here it is, program, credit card
details, everything but the key.)
1. The credit card details:
string =
'\x84ue\x8d\xec\x98\x02\xba<n\t\xc6\xa6\xd2\xcc\xe4O\x11\xd7\xf5\xe7\x9c\xe
d
*\x05\x1e\xb3h\x97V\xf8\x9a"%\xec\x14\x03r\xdd\xda\x18\xc0\x9fc\x04&J\xefF\
x
cd\xbc\x81\xad\xfe\xb4SV\x1a7[l\x12\xfd\xc9w\xc3u\xf4\x83tK\x1e]{\xf5/\xbfJ
\
x8a\xde\x18\xc2jj\xe8er\x10\x99\x1e\xeb\xa3\x86\xf0f\xb9\x95\xb5\xd8\xaaY\x
0 8\xb8\xcdf.'
2. The decoding program
def cyrep (string, key):
"""To encrypt use a numeric value as the key. To decrypt use the
negative value of the same number."""
import random
CHUNK = 32
def process_sequence (sequence):
s = ''
for i in xrange (len (sequence)):
r = random.randint (0, 255)
s += chr ((ord (sequence
) + r * sign) % 256)
return s
def preprocess_sequence (sequence):
random.shuffle (sequence)
return sequence
sign = (key > 0) * 2 - 1
random.seed (abs (key * sign))
i = 0
s = ''
if sign > 0:
while i < len (string):
chunk = random.randint (0, CHUNK)
s_ = preprocess_sequence (list (string [i:i+chunk]))
s += ''.join (process_sequence (s_))
i += len (s_)
else:
while i < len (string):
chunk = random.randint (0, CHUNK)
s_ = list (string [i:i+chunk])
l = len (s_)
l_ = range (l)
s__ = l * [None]
o = preprocess_sequence (l_)
s_ = process_sequence (s_)
for ii in l_:
s__ [o[ii]] = s_ [ii]
s += ''.join (s__)
i += l
return s
----- Original Message -----
From: "Christos TZOTZIOY Georgiou" <[email protected]>
Newsgroups: comp.lang.python
To: <[email protected]>
Sent: Friday, May 13, 2005 11:06 AM
Subject: Re: Encryption with Python?
f
x
\
f
and given that
is
sequence.
can we suppose that the encrypted text above are the details of your
credit card (number, name as written on it, expiry date, billing address
and your first dog's name)? Do you trust the 'unbreakability' of your
algorithm that much?