Exemplo n.º 1
0
        /// Encodes the specified string.
        /// @param text The string to encode.
        /// @returns The encoded string.
        public string Encode(string text)
        {
            var buffer = Encoding.Default.GetBytes(text);
            var hash   = SHA224.Create().ComputeHash(buffer);

            return(HexCodec.GetString(hash));
        }
Exemplo n.º 2
0
        public virtual void Create()
        {
            // Note: These tests will only be valid without a "machine.config" file
            // or a "machine.config" file that do not modify the default algorithm
            // configuration.
// FIXME: Change namespace when (or if) classes are moved into corlib
            const string defaultSHA224 = "Mono.Security.Cryptography.SHA224Managed";

            // try to build the default implementation
            SHA224 hash = SHA224.Create();

            Assert.AreEqual(hash.ToString(), defaultSHA224, "SHA224.Create()");

            // try to build, in every way, a SHA224 implementation
            hash = SHA224.Create("SHA224");
            Assert.AreEqual(hash.ToString(), defaultSHA224, "SHA224.Create('SHA224')");
            hash = SHA224.Create("SHA-224");
            Assert.AreEqual(hash.ToString(), defaultSHA224, "SHA224.Create('SHA-224')");
        }
Exemplo n.º 3
0
 public virtual void SetUp()
 {
     hash = SHA224.Create();
 }
Exemplo n.º 4
0
 public void CreateNull()
 {
     // try to build null implementation
     hash = SHA224.Create(null);
 }
Exemplo n.º 5
0
 public void CreateIncorrect()
 {
     // try to build an incorrect hash algorithms
     hash = SHA224.Create("MD5");
 }