public static bool TryParse(string s, out SecretShare share) { var match = _Parser.Match(s); FiniteFieldPoint point; if(!FiniteFieldPoint.TryParse(match, out point)) { share = null; return false; } if(!match.Success) { share = null; return false; } var rawShareType = match.Groups["shareType"].Value; var shareType = String.IsNullOrWhiteSpace(rawShareType) ? "0" : rawShareType; int shareTypeVal; if(!Int32.TryParse(shareType, NumberStyles.Integer, CultureInfo.InvariantCulture, out shareTypeVal)) { share = null; return false; } var checksum = match.Groups["checksum"].Value ?? ""; share = new SecretShare((SecretShareType) shareTypeVal, point, checksum); share.ParsedValue = s; return true; }
public static bool TryParse(string s, out SecretShare share) { var match = _Parser.Match(s); FiniteFieldPoint point; if (!FiniteFieldPoint.TryParse(match, out point)) { share = null; return(false); } if (!match.Success) { share = null; return(false); } var rawShareType = match.Groups["shareType"].Value; var shareType = String.IsNullOrWhiteSpace(rawShareType) ? "0" : rawShareType; int shareTypeVal; if (!Int32.TryParse(shareType, NumberStyles.Integer, CultureInfo.InvariantCulture, out shareTypeVal)) { share = null; return(false); } var checksum = match.Groups["checksum"].Value ?? ""; share = new SecretShare((SecretShareType)shareTypeVal, point, checksum); share.ParsedValue = s; return(true); }
public static CombinedSecret Combine(string allShares) { return(Combine(Regex.Matches(allShares, SecretShare.RegexPattern).OfType <Match>().Select(m => SecretShare.Parse(m.Value)), DefaultDiffuser)); }