Note that there are some explanatory texts on larger screens.

plurals
  1. POPermuting on a schedule python
    primarykey
    data
    text
    <p>I'm trying to implement simplified DES for learning purposes in python, but I am having trouble figuring out how to do the permutations based on a "schedule." Essentially, I have a tuple with the appropriate permutations, and I need to bit shift to the correct location.</p> <p>For example, using a key:</p> <p>K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001</p> <p>Would move the 57st bit to the first bit spot, 49th bit to the second bit spot, etc...</p> <p>K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111</p> <p>Current code:</p> <pre><code>def keyGen(key): PC1table = (57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4) keyBinary = bin(int(key, 16))[2:].zfill(64) print keyBinary permute(PC1table, keyBinary) def permute(permutation, permuteInput): elements = list(enumerate(permutation)) for bit in permuteInput: ***magic bitshifting goes here*** keyGen("133457799BBCDFF1") </code></pre> <p>The logic I thought would work was to enumerate the tuple of permutations, and for each bit of my old key, look in the enumeration to find the index corresponding the the bit, and bit shift the appropriate number of times, but I just can't figure out how to go about doing this. It may be that I am approaching the problem from the wrong angle, but any guidance would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload