Esempio n. 1
0
        /// <summary>
        /// Converts a glyph character into an index of the current <see cref="EncodingWheel"/>. This method is Case-sensitive
        /// </summary>
        /// <param name="glyph">Input character that will be transposed into an <see cref="EncodingWheel"/> index</param>
        /// <returns>An index of the <see cref="EncodingWheel"/> where the input glyph is located</returns>
        public virtual char TransposeGlyph(char glyph)
        {
            GlyphCollection glyphs = EncodeWheel.Glyphs;

            for (int x = 0; x < glyphs.Count; x++)
            {
                if (glyphs[x] == glyph)
                {
                    return((char)x);
                }
            }

            throw new IndexOutOfRangeException("The input glyph cannot be found on the current Encoding Wheel.");
        }
Esempio n. 2
0
        /// <summary>
        /// Converts an string of indices from the current <see cref="EncodingWheel"/> into an string of characters
        /// </summary>
        /// <param name="input">Input string of indices from the current <see cref="EncodingWheel"/> to transpose into an string of characters</param>
        /// <returns>A transposed string of characters generated using the current <see cref="EncodingWheel"/> and the given string of indices</returns>
        public virtual string TransposeIndices(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                throw new ArgumentNullException(nameof(input));
            }

            StringBuilder   str    = new StringBuilder(input.Length);
            GlyphCollection glyphs = EncodeWheel.Glyphs;

            for (int i = 0; i < input.Length; i++)
            {
                str.Append(glyphs[(int)input[i]]);
            }

            return(str.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// Sanitizes an input hash for further validation and processing, removing unneeded delimiters and applying an standardized format
        /// </summary>
        /// <param name="hash">Input hash to be formatted</param>
        /// <returns>A new standardized hash with all formatting rules applied to it</returns>
        public string SanitizeHash(string hash)
        {
            if (string.IsNullOrEmpty(hash))
            {
                throw new ArgumentNullException(nameof(hash));
            }

            StringBuilder   str    = new StringBuilder(hash.Length);
            GlyphCollection glyphs = EncodeWheel.Glyphs;

            glyphs = new GlyphCollection(new string(glyphs.ToArray()).ToUpperInvariant().ToCharArray());
            hash   = hash.ToUpperInvariant();
            for (int i = 0; i < hash.Length; i++)
            {
                if (glyphs.Contains(hash[i]))
                {
                    str.Append(hash[i]);
                }
            }

            return(str.ToString().ToUpperInvariant());
        }
Esempio n. 4
0
        /// <summary>
        /// Converts an string of glyphs into an string of indices using the current <see cref="EncodingWheel"/>. This method is Case-sensitive
        /// </summary>
        /// <param name="input">Input string of characters to transpose into indices for the <see cref="EncodingWheel"/></param>
        /// <returns>A transposed string of indices for the <see cref="EncodingWheel"/> that represents each Glyph present on the input</returns>
        public virtual string TransposeGlyphs(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                throw new ArgumentNullException(nameof(input));
            }

            StringBuilder   str    = new StringBuilder(input.Length);
            GlyphCollection glyphs = EncodeWheel.Glyphs;

            for (int i = 0; i < input.Length; i++)
            {
                for (int x = 0; x < glyphs.Count; x++)
                {
                    if (glyphs[x] == input[i])
                    {
                        str.Append((char)x);
                        break;
                    }
                }
            }

            return(str.ToString());
        }