Ejemplo n.º 1
0
        /// <summary>
        /// String info for the manager
        /// </summary>
        /// <returns>The string info that the manager contains</returns>
        public override string ToString()
        {
            var Builder = new StringBuilder();

            Builder.AppendLineFormat("Asymmetric algorithms: {0}", AsymmetricAlgorithms.ToString(x => x.Name));
            Builder.AppendLineFormat("Hashing algorithms: {0}", HasherAlgorithms.ToString(x => x.Name));
            Builder.AppendLineFormat("Shift algorithms: {0}", ShiftAlgorithms.ToString(x => x.Name));
            Builder.AppendLineFormat("Symmetric algorithms: {0}", SymmetricAlgorithms.ToString(x => x.Name));
            return(Builder.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Hashes the data
        /// </summary>
        /// <param name="Data">Data to hash</param>
        /// <param name="Algorithm">Algorithm</param>
        /// <returns>The hashed data</returns>
        public byte[] Hash(byte[] Data, string Algorithm)
        {
            Contract.Requires <NullReferenceException>(HasherAlgorithms != null, "HasherAlgorithms");
            var Found = HasherAlgorithms.FirstOrDefault(x => x.CanHandle(Algorithm));

            if (Found == null)
            {
                throw new ArgumentException(Algorithm + " not found");
            }
            return(Found.Hash(Data, Algorithm));
        }