## Background

The unix crypt algorithm used a symmetric encryption algorithm to construct a hash. It did it by starting with a fixed string (i.e. the same every time) and encrypting it using the message/password as the key. The output was then re-encrypted with the same key. Then that output was re-encrypted with that same key, and so on. We will do the same thing, except that we shift the string various amounts prior to encrypting. This is needed because of the basic weakness of the Caesar and Vigenere ciphers.

## Left shift of a string

If you have a string s0 s1 s2 ... sn-1, its left shift is s1 s2 ... sn-1 s0. Its shift left by k places is simply the result of k left shifts.
```Examples:
str = abcdefghijk
left shift of str = bcdefghijka

str = abcdefghijk
shift left by 3 places of str = defghijkabc
```

## The Shift+encalg Hash

Assuming that you have an encryption algorithm encalg and a message/password pswd, here's how to compute the shift+ hash:
```1. x = "GO_NAVY_2018^mid"  ← this 16 character string is called the "initialization vector"
2. for i from 0 up to 15 do
c = character at index i in string x
k = (ASCII value of c) mod 16
shift x left by k places ← Note: x is modified!
x = encryption of x with key pswd using algorithm encalg
3. return x as the hash value```

## A little bit of explanation (optional) and some useful debugging info

Although it's outside the scope of what you really need to know to do this project, it's interesting to see why we need to do things multiple times. One important property a cryptographic hash should have is that very similar passwords should lead to totally different hashes. In the table below, I've laid out the intermediate x-values printed out by shift+vigenere on two passwords that differ by only one letter. What we see is that the results are very similar in the first few rounds, but diverge as we go through more and more iterations.

 hash algorithm: shift+vigeneremessage/password: grumpy hash algorithm: shift+vigeneremessage/password: grompy ``` before loop x = GO_NAVY_2018^mid after i = 00 x = Kz*t-\Y`^9D]:8PK after i = 01 x = 0T4*EI7qufsZEWX+ after i = 02 x = 1@1cjd_Q?IMzmK.m after i = 03 x = Oa^QF=5Dt_@,Yy:t after i = 04 x = r;nQ5*Ep4fD_JH@/ after i = 05 x = 0VD:5-^2hC*y1g.X after i = 06 x = kO*H98ruXu]Agp+Y after i = 07 x = uioJj[-^jnNi;rB+ after i = 08 x = :`5d7za`i<_YjUd` after i = 09 x = VL^R/^r[1lV^U3YK after i = 10 x = ^R+^K\A*S=KJJIzP after i = 11 x = 7AD;oNJIvP@Z-rM/ after i = 12 x = ^Dzz6BxfH<>t<7Tp after i = 13 x = R?60i:tKjP9xf-l0N<;_o]o ``` ``` before loop x = GO_NAVY_2018^mid after i = 00 x = Kzut-\Y`X9D]:8JK after i = 01 x = 0T.*?I7qifsZEWL+ after i = 02 x = 8suFty+@+c^d_Q9I after i = 03 x = h7pUSbKH-;-qa=hk after i = 04 x = AJV==+xueS2fW_+b after i = 05 x = RNSnW?6M1/qva\Gu after i = 06 x = sDvrftMS;gGL?eK1 after i = 07 x = ^]h?H9S>@1ZInj8h after i = 08 x = JT\1=7?54tOGZa,Z after i = 09 x = z.3xzr;>NSrX6KPt after i = 10 x = pond0<:JfJ+IX after i = 12 x = LPskw

Of course shift+clear is a terrible hash algorithm. Turns out shift+caesar isn't much good either ... after all, the password is mapped to a "shift character" and there are only 81 of those. However, shift+vigenere is actually not too bad. Certainly you should find that different passwords seem to give rise to totally different hashes regardless of how close the passwords are.

## More Examples to Help With Debugging

 hash algorithm: shift+vigeneremessage/password: hotcakes hash algorithm: shift+vigeneremessage/password: hotcekes ``` before loop x = GO_NAVY_2018^mid after i = 00 x = LwzjoNWaQ;HG41@Q after i = 01 x = NE40-ul8>@pbP_8O after i = 02 x = kiequ0ZZ=S1745oy after i = 03 x = VYj]gJD5@v0ml_cc after i = 04 x = s4oiS\I[PJRRCW4< after i = 05 x = 0K-uYuYa@PBC6:]a5^iaqBBs?[/qv after i = 14 x = NDNwOQ[:/g8Cfa`O after i = 15 x = @pbTc8O after i = 02 x = omeqy0ZZAW1785oy after i = 03 x = ZYjakJD9Dv0qp_cg after i = 04 x = ^dXKQJCbN_C,t4`y after i = 05 x = 0qmmJiH\E?J2-R8W after i = 06 x = 23CkhBsOnefU4Y2T after i = 07 x = Aw,+UX,k=Z;@?Cd=h after i = 15 x = M\VYyTx`8=yCEk7e ```

 hash algorithm: shift+caesarmessage/password: hotcakes hash algorithm: shift+vigeneremessage/password: hotcekes ``` before loop x = GO_NAVY_2018^mid after i = 00 x = <`^_f;JFAu,<+o36 after i = 01 x = j=;AGkijqFUQL/7 after i = 03 x = ]eudWlouHFGNt2.z after i = 04 x = Rvtu+Q`\W:BRA4IL after i = 05 x = SQRY.=94hp/obwz/ after i = 06 x = M]L?TW]0./6\kgbE after i = 07 x = *:zm14:^\]d9HD?s after i = 08 x = vrmPXhWJ_bh;9:Ag after i = 09 x = J-5E4x9mu4tg+.4XVW after i = 04 x = H]`f978?etpkNVfU after i = 05 x = qFUQL/7G6z>AGkij after i = 06 x = yh[psyLJKRx62-ai after i = 07 x = Yhd_BJZI?Fl*wrU]m after i = 10 x = \XS6>N=0EHNrpqxM after i = 11 x = 4hp/obwz/SQRY.=9 after i = 12 x = 423:`okfIQaPCX[a after i = 13 x = *2B1u9

 hash algorithm: shift+clearmessage/password: hotcakes hash algorithm: shift+clearmessage/password: hotcekes ``` before loop x = GO_NAVY_2018^mid after i = 00 x = _2018^midGO_NAVY after i = 01 x = 018^midGO_NAVY_2 after i = 02 x = O_NAVY_2018^midG after i = 03 x = _NAVY_2018^midGO after i = 04 x = 8^midGO_NAVY_201 after i = 05 x = _NAVY_2018^midGO after i = 06 x = AVY_2018^midGO_N after i = 07 x = ^midGO_NAVY_2018 after i = 08 x = midGO_NAVY_2018^ after i = 09 x = Y_2018^midGO_NAV after i = 10 x = midGO_NAVY_2018^ after i = 11 x = dGO_NAVY_2018^mi after i = 12 x = _2018^midGO_NAVY after i = 13 x = 2018^midGO_NAVY_ after i = 14 x = O_NAVY_2018^midG after i = 15 x = 2018^midGO_NAVY_ ``` ``` before loop x = GO_NAVY_2018^mid after i = 00 x = _2018^midGO_NAVY after i = 01 x = 018^midGO_NAVY_2 after i = 02 x = O_NAVY_2018^midG after i = 03 x = _NAVY_2018^midGO after i = 04 x = 8^midGO_NAVY_201 after i = 05 x = _NAVY_2018^midGO after i = 06 x = AVY_2018^midGO_N after i = 07 x = ^midGO_NAVY_2018 after i = 08 x = midGO_NAVY_2018^ after i = 09 x = Y_2018^midGO_NAV after i = 10 x = midGO_NAVY_2018^ after i = 11 x = dGO_NAVY_2018^mi after i = 12 x = _2018^midGO_NAVY after i = 13 x = 2018^midGO_NAVY_ after i = 14 x = O_NAVY_2018^midG after i = 15 x = 2018^midGO_NAVY_ ```