public bool CreateValue(HexValue hexValue) { _hexValue = hexValue; if (_hexValue == null) { Console.WriteLine("HexValue is null, can\'t calculate value without."); return(false); } if (!HexHashUtil.TryHexPosConversion(Position, Size, Salted ? hexValue.Salted : hexValue.UnSalted, out var result)) { Console.WriteLine($"CreateValue, failed trying to convert hex position.{Position}, {Size}, {Salted}"); return(false); } var modValue = result % (Creation - MinRange) + MinRange; if (Math.Abs(modValue % 1) > Double.Epsilon) { Console.WriteLine($"CreateValue, failed to cast double in same int value.{modValue},{(int)modValue}"); return(false); } _value = (int)modValue; return(true); }
public bool CreateValue(HexValue hexValue) { this._hexValue = hexValue; if (this._hexValue == null) { Console.WriteLine($"HexValue is null, can't calculate value without."); return(false); } if (!HexHashUtil.TryHexPosConversion(Position, Size, Salted? hexValue.Salted : hexValue.UnSalted, out double result)) { Console.WriteLine($"CreateValue, failed trying to convert hex position.{Position}, {Size}, {Salted}"); return(false); } double modValue = (result % (Creation - MinRange)) + MinRange; if (modValue % 1 != 0) { Console.WriteLine($"CreateValue, failed to cast double in same int value.{modValue},{(int)modValue}"); return(false); } value = (int)modValue; return(true); }
private static int GetMinLength(List <char[]> unSalted, int minLength, int maxLength) { int result = 0; for (int i = 1; i < 10; i++) { if (HexHashUtil.TryHexPosConversion(i, 1, unSalted, out double value)) { result += (int)value; } if (result > minLength - 1 & i > 3) { if (result < maxLength) { return(result); } else { result = maxLength; } } } return(maxLength - 1); }
public static string GenerateName(HexValue hexValue) { var minLength = GetMinLength(hexValue.UnSalted, 3, 9); string[] consonants = { "b", "c", "ck", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "sh", "zh", "t", "v", "w", "x" }; string[] vowels = { "a", "e", "i", "o", "u", "ae", "y" }; var name = ""; if (HexHashUtil.TryHexPosConversion(4, 2, hexValue.UnSalted, out var seedValues)) { name += consonants[(int)seedValues % consonants.Length]; } if (HexHashUtil.TryHexPosConversion(6, 2, hexValue.UnSalted, out seedValues)) { name += vowels[(int)seedValues % vowels.Length]; } var ind = 8; var consonantNow = true; while (name.Length < minLength) { if (consonantNow && HexHashUtil.TryHexPosConversion(ind, 2, hexValue.UnSalted, out seedValues)) { name += consonants[(int)seedValues % consonants.Length]; } else if (HexHashUtil.TryHexPosConversion(ind, 2, hexValue.UnSalted, out seedValues)) { name += vowels[(int)seedValues % vowels.Length]; } else { Log.Error("Generating names seems currently troublesome!"); } consonantNow = !consonantNow; ind += 2; } return(name.First().ToString().ToUpper() + name.Substring(1)); }