1. 程式人生 > >DES加密祕鑰

DES加密祕鑰

1 祕鑰長度

Each algorithm is designed to accept a certain key length. The key is used as part of the algorithm, and as such, can’t be whatever your heart desires.

Common key sizes are:

DES: 56bit key
AES: 128-256bit key (commonly used values are 128, 192 and 256)
RSA (assymetric cryptography): 1024, 2048, 4096 bit key

The key must have size 64-bits but only 56-bits are used from the key. The other 8-bits are parity bits (internal use).

2 校驗位

DES演算法的加密金鑰是根據使用者輸入的密碼生成的,該演算法把64位密碼中的第8位、第16位、第24位、第32位、第40位、第48位、第56位、第64位作為奇偶校驗位,在計算金鑰時要忽略這8位.如果輸入的密碼只是在這8位上有區別的話,那麼操作後的結果將是一樣的.
例:
輸入的密碼為wuzhenll,金鑰的16進製表示為77 75 7A 68 65 6E 6C 6C
任意改變這64位資料的奇偶校驗位,可以得到16個不同的密碼,
把8個奇偶檢驗位全取反後:
w->v
u->t
z->{
h->i
e->d
n->o
l->m
形成新密碼:vt{idomm
表面上新密碼和原密碼迥然不同,但是由於他們僅在奇偶校驗位上有區別,所以用這兩個密碼進行加密解密操作得到的結果是一樣的.

參考

1、How should I create my DES key? Why is an 7-character string not enough?
2、DES演算法中金鑰的校驗位