I'm wondering if the Vegenere cipher could be more secure if the key generation technique below is used...
In this method, the first key is the SHA-512 hash of the given password. When all 64 bytes of that key have been used, another key is generated, this one being the SHA-512 hash of the previous key. This is repeated until the encryption is complete.
This method is an attempt to foil the Kasiski examination.
The equations for encryption/decryption are:
Ci = Pi + Ki (mod 256)
Pi = Ci - Ki (mod 256)
Which are modified from the original equations so that they can be used on computers with any type of file, not just text.
Edit: Guess I should post the code!
Code:public void VigEncryptData(string inFile, string outFile, string password) { SHA512 hash = new SHA512Managed(); byte[] key = hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(password)); FileStream fin = new FileStream(inFile, FileMode.Open, FileAccess.Read); FileStream fout = new FileStream(outFile, FileMode.OpenOrCreate, FileAccess.Write); int i=0, ii=0; while(i < fin.Length) { int c = fin.ReadByte(); c = (int)(c + key[ii] % 256); fout.WriteByte((byte)c); if(ii == key.Length-1) { key = hash.ComputeHash(key); ii = 0; } i++; ii++; } fin.Close(); fout.Close(); }



LinkBack URL
About LinkBacks



)