public int Encode(int input) { IEnumerable <int> roundKeys = KeyScheduler.GetRoundKeys(RoundCount); for (int i = 0; i < RoundCount; i++) { // Add Round Key input = AddRoundKey(input, roundKeys.ElementAt(i)); // SBox Substitution byte[] inputBytes = GetBytes(input); for (int j = 0; j < 4; j++) { inputBytes[j] = Substitution.Substitute(inputBytes[j]); } input = GetInt(inputBytes); // Permutation Layer Except Last Round if (i != RoundCount - 1) { input = Permutation.Permutate(input); } } // Add Last Round Key input = AddRoundKey(input, roundKeys.Last()); return(input); }
public override string GetState(Newtonsoft.Json.Linq.JObject jobject) { var result = Response; Substitution s = new Substitution(); Dictionary<string, string> pairs = new Dictionary<string, string>(); pairs["PropertyName"] = PropertyName; pairs["PropertyValue"] = GetValue(jobject, PropertyName); pairs["PropertyHasValue"] = (jobject[PropertyName] != null).ToString().ToLower(); result = s.Substitute(result, pairs); return result; }
public override string GetState(JObject jobject) { string result = ""; result = Response; Substitution s = new Substitution(); Dictionary<string, string> pairs = new Dictionary<string, string>(); pairs["PropertyName"] = PropertyName; pairs["PropertyValue"] = GetValue(jobject, PropertyName); pairs["PropertyHasValue"] = (jobject[PropertyName] != null).ToString().ToLower(); pairs["MinimumLength"] = MinimumLength.ToString(); pairs["ActualLength"] = ActualLength.ToString(); pairs["Kind"] = "GreaterThan"; result = s.Substitute(result, pairs); return result; }