コード例 #1
0
ファイル: SecretShare.cs プロジェクト: giuliov/SecretSplitter
        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;
        }
コード例 #2
0
ファイル: SecretShare.cs プロジェクト: n4074/SecretSplitter
        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);
        }
コード例 #3
0
 public static CombinedSecret Combine(string allShares)
 {
     return(Combine(Regex.Matches(allShares, SecretShare.RegexPattern).OfType <Match>().Select(m => SecretShare.Parse(m.Value)), DefaultDiffuser));
 }