0

Is there any possible way to filter a key space in a crypto-system to get a set of keys that decrypts out a valid text (text that is in same language or readable)?

I tried a random approach and got certain set of keys but its not that appreciative to actually required text size

code

from Crypto.Cipher import ARC4
import base64, string, time, random
key = ''.join(random.choice(string.ascii_letters + string.digits ) for i in       range(8))
obj1 = ARC4.new(key)
obj2 = ARC4.new(key)
text = 'abcdefgh'
cipher_text = base64.b64encode(obj1.encrypt(text))

decoded_text= obj2.decrypt(base64.b64decode(cipher_text))

Dict={}
count=0
valid = set(string.ascii_letters + string.digits )
def test(s):
    return set(s).issubset(valid)

print; print 'plain text: ', text
print; print 'Actual key: ', key 
print; print 'Cipher text: ', cipher_text

timeout=time.time()+60
while time.time()< timeout:
   count+=1
   key = ''.join(random.choice(string.ascii_letters + string.digits ) for i in range(8))
   obj2 = ARC4.new(key)
   decoded= obj2.decrypt(base64.b64decode(cipher_text))
   if test(decoded):
       Dict.update({'key: '+key : 'Valid Decrypted Text: '+decoded})
import pprint
print; print 'Analysis: '
pprint.pprint(Dict)
print;print 'Number of valid Decrypted Text: ', len(Dict)
print;print 'Total number of decryption performed: ', count

Output:

plain text:  abcdefgh

Actual key:  go6oMkCG

Cipher text:  JB1a3osG+es=

Analysis: 
{'key: 0UUvjzLw': 'Valid Decrypted Text: mzptBVo4',

 'key: 2beOXKN1': 'Valid Decrypted Text: Yhz3jIL8',

 'key: 3Eq7MKwu': 'Valid Decrypted Text: GA9BTdzy',

 'key: 3jUQPXs8': 'Valid Decrypted Text: 3gCa3KBG',

.

.

Number of valid Decrypted Text:  36

Total number of decryption performed:  2275140

Is there any better to sort out such keys. Such keys may be valuable to strengthen cryptography by introducing confusion

ceasif
  • 345
  • 2
  • 14
  • They already created a lot of confusion it seems. A good cipher does not need "confusion". Better asked at http://crypto.stackexchange.com/ as this question is not really to do with programming, you want to know how to create this confusion. But beware, you may want to wear a thick skin :) – Maarten Bodewes Apr 22 '14 at 22:36
  • . I think the complexity of cryptography is a challenge to processing capability. – ceasif Apr 23 '14 at 05:43
  • Yes it is, but it is already complex without these special keys. – Maarten Bodewes Apr 23 '14 at 07:13

0 Answers0