source: trunk/CrypPlugins/PKCS1/Library/Hashfunction.cs @ 1893

Last change on this file since 1893 was 1778, checked in by schomburg, 11 years ago

renamed some classes for the sake of consistency

File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Org.BouncyCastle.Crypto;
6using Org.BouncyCastle.Security;
7
8namespace PKCS1.Library
9{
10    class Hashfunction
11    {
12        private static IDigest hashFunctionDigest = DigestUtilities.GetDigest(HashFuncIdentHandler.SHA1.diplayName); // default SHA1
13       
14        public static byte[] generateHashDigest(string input, HashFunctionIdent hashIdent)
15        {
16            byte[] bInput = Encoding.ASCII.GetBytes(input);
17            return generateHashDigest(ref bInput, ref hashIdent);
18        }
19
20        public static byte[] generateHashDigest(ref byte[] input, ref HashFunctionIdent hashIdent)
21        {   
22            hashFunctionDigest = DigestUtilities.GetDigest(hashIdent.diplayName);
23            byte[] hashDigest = new byte[hashFunctionDigest.GetDigestSize()];
24            hashFunctionDigest.BlockUpdate(input, 0, input.Length);
25            hashFunctionDigest.DoFinal(hashDigest, 0);           
26
27            return hashDigest;
28        }
29
30        // gibt länge in bytes zurück!
31        public static int getDigestSize()
32        {
33            return hashFunctionDigest.GetDigestSize();
34        }
35
36        public static string getAlgorithmName()
37        {
38            return hashFunctionDigest.AlgorithmName;
39        }
40    }
41}
Note: See TracBrowser for help on using the repository browser.