您当前的位置:五五电子网电子知识单片机-工控设备综合-其它DES算法程序 正文
DES算法程序

DES算法程序

点击数:7946 次   录入时间:03-04 11:47:04   整理:http://www.55dianzi.com   综合-其它


/* des: duplicate the NBS Data Encryption Standard in software.
 * usage: des <file>
 * prompts for the password
 * If the filename ends in ".n" it will be decrypted with the key;
 * otherwise it will be encrypted.
 *
 * Permutation algorithm:
 * The permutation is defined by its effect on each of the 16 nibbles
 * of the 64-bit input.  For each nibble we give an 8-byte bit array
 * that has the bits in the input nibble distributed correctly.  The
 * complete permutation involves ORing the 16 sets of 8 bytes designated
 * by the 16 input nibbles.  Uses 16*16*8 = 2K bytes of storage for
 * each 64-bit permutation.  32-bit permutations (P) and expansion (E)
 * are done similarly, but using bytes instead of nibbles.
 * Should be able to use long ints, adding the masks, at a
 * later pass.  Tradeoff: can speed 64-bit perms up at cost of slowing
 * down expansion or contraction operations by using 8K tables here and
 * decreasing the size of the other tables.
 * The compressions are pre-computed in 12-bit chunks, combining 2 of the
 * 6->4

本文关键字:程序  综合-其它单片机-工控设备 - 综合-其它