public static byte[] BasylHashUno(String str, string pass, int hashSize, int keySize, int rounds, int skipOver, string additionalPass) { PseudoRandomGenerator prng = new PseudoRandomGenerator(keySize, pass, rounds); prng.SetRecycleKey(additionalPass); IBasylKeyGenerator wk = new BasylWeakKeyGenerator(prng); BESCipher cipher = new BESCipher(wk); prng.Recycle(); foreach (char n in str) { byte q = (byte)n; cipher.EncryptLeft(ref q); } for (int i = 0; i < skipOver; i++) { for (int x = 0; x < 4; x++) { prng.GetRandomByte(); } } int max = prng.GetRandomByte() * prng.GetRandomByte() + prng.GetRandomByte(); for (int i = 0; i < max; i++) { for (int x = 0; x < 4; x++) { prng.GetRandomByte(); } } byte[] BHU = new byte[hashSize]; wk.FillBytes(BHU, 0, BHU.Length); for (int i = 0; i < hashSize; i++) { BHU[i] ^= prng.GetRandomByte(); cipher.EncryptRight(ref BHU); } return(BHU); }
public static byte[] BasylHashUno(String str, string pass, int hashSize, int keySize, int rounds, int skipOver, string additionalPass) { PseudoRandomGenerator prng = new PseudoRandomGenerator(keySize, pass, rounds); prng.SetRecycleKey(additionalPass); IBasylKeyGenerator wk = new BasylWeakKeyGenerator(prng); BESCipher cipher = new BESCipher(wk); prng.Recycle(); foreach(char n in str) { byte q = (byte)n; cipher.EncryptLeft(ref q); } for (int i = 0; i < skipOver; i++) { for (int x = 0; x < 4; x++ ) prng.GetRandomByte(); } int max = prng.GetRandomByte() * prng.GetRandomByte() + prng.GetRandomByte(); for (int i = 0; i < max; i++) { for (int x = 0; x < 4; x++) prng.GetRandomByte(); } byte[] BHU = new byte[hashSize]; wk.FillBytes(BHU, 0, BHU.Length); for (int i = 0; i < hashSize; i++) { BHU[i] ^= prng.GetRandomByte(); cipher.EncryptRight(ref BHU); } return BHU; }