<reponame>aadishgoel2013/Cryptography-Codes<filename>DESkeyGenerator.py
# DES Key Generator :AAG
while True: 
    key = input('Enter 8 char key: ')
    if len(key)==8: break
    else: print('Invalid Key Enter Again')

k = ''
for i in key:
    k+=bin(ord(i))[2:]


for i in range(1,17): 
    s=2
    x1,y1 = k[:28],k[28:]
    if i in [1,2,9,16]:
        s=1
    x1 = x1[s:] + x1[:s]
    y1 = y1[s:] + y1[:s]
    k = x1+y1 
    print('key number',i,'is',k)

'''   Output :-
Enter 8 char key: <KEY>
key number 1 is 10000111000101100011110010011001011100110110011111010001
key number 2 is 00001110001011000111100100110010111001101100111110100011
key number 3 is 00111000101100011110010011001011100110110011111010001100
key number 4 is 11100010110001111001001100001110011011001111101000110010
key number 5 is 10001011000111100100110000111001101100111110100011001011
key number 6 is 00101100011110010011000011100110110011111010001100101110
key number 7 is 10110001111001001100001110001011001111101000110010111001
key number 8 is 11000111100100110000111000101100111110100011001011100110
key number 9 is 10001111001001100001110001011001111101000110010111001101
key number 10 is 00111100100110000111000101100111110100011001011100110110
key number 11 is 11110010011000011100010110001111010001100101110011011001
key number 12 is 11001001100001110001011000111101000110010111001101100111
key number 13 is 00100110000111000101100011110100011001011100110110011111
key number 14 is 10011000011100010110001111000001100101110011011001111101
key number 15 is 01100001110001011000111100100110010111001101100111110100
key number 16 is 11000011100010110001111001001100101110011011001111101000
'''

# DES Key Generator :AAG
while True: 
    key = input('Enter 8 char key: ')
    if len(key)==8: break
    else: print('Invalid Key Enter Again')

k = ''
for i in key:
    k+=bin(ord(i))[2:]


for i in range(1,17): 
    s=2
    x1,y1 = k[:28],k[28:]
    if i in [1,2,9,16]:
        s=1
    x1 = x1[s:] + x1[:s]
    y1 = y1[s:] + y1[:s]
    k = x1+y1 
    print('key number',i,'is',k)

'''   Output :-
Enter 8 char key: <KEY>
key number 1 is 10000111000101100011110010011001011100110110011111010001
key number 2 is 00001110001011000111100100110010111001101100111110100011
key number 3 is 00111000101100011110010011001011100110110011111010001100
key number 4 is 11100010110001111001001100001110011011001111101000110010
key number 5 is 10001011000111100100110000111001101100111110100011001011
key number 6 is 00101100011110010011000011100110110011111010001100101110
key number 7 is 10110001111001001100001110001011001111101000110010111001
key number 8 is 11000111100100110000111000101100111110100011001011100110
key number 9 is 10001111001001100001110001011001111101000110010111001101
key number 10 is 00111100100110000111000101100111110100011001011100110110
key number 11 is 11110010011000011100010110001111010001100101110011011001
key number 12 is 11001001100001110001011000111101000110010111001101100111
key number 13 is 00100110000111000101100011110100011001011100110110011111
key number 14 is 10011000011100010110001111000001100101110011011001111101
key number 15 is 01100001110001011000111100100110010111001101100111110100
key number 16 is 11000011100010110001111001001100101110011011001111101000
'''
# DES Key Generator :AAG Output :-
 Enter 8 char key: <KEY>
 key number 1 is 10000111000101100011110010011001011100110110011111010001
 key number 2 is 00001110001011000111100100110010111001101100111110100011
 key number 3 is 00111000101100011110010011001011100110110011111010001100
 key number 4 is 11100010110001111001001100001110011011001111101000110010
 key number 5 is 10001011000111100100110000111001101100111110100011001011
 key number 6 is 00101100011110010011000011100110110011111010001100101110
 key number 7 is 10110001111001001100001110001011001111101000110010111001
 key number 8 is 11000111100100110000111000101100111110100011001011100110
 key number 9 is 10001111001001100001110001011001111101000110010111001101
 key number 10 is 00111100100110000111000101100111110100011001011100110110
 key number 11 is 11110010011000011100010110001111010001100101110011011001
 key number 12 is 11001001100001110001011000111101000110010111001101100111
 key number 13 is 00100110000111000101100011110100011001011100110110011111
 key number 14 is 10011000011100010110001111000001100101110011011001111101
 key number 15 is 01100001110001011000111100100110010111001101100111110100
 key number 16 is 11000011100010110001111001001100101110011011001111101000