KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > maverick > crypto > digests > DigestFactory


1 package com.maverick.crypto.digests;
2
3 public class DigestFactory {
4
5
6     static DigestProvider provider = null;
7
8     public DigestFactory() {
9     }
10
11     public static void setProvider(DigestProvider provider) {
12         DigestFactory.provider = provider;
13     }
14
15     public static Digest createDigest(String JavaDoc type) {
16
17         if(provider!=null)
18             return provider.createDigest(type);
19         else {
20             if(type.equals("MD5")) {
21                 return new MD5Digest();
22             }
23             else {
24                 return new SHA1Digest();
25             }
26         }
27     }
28 }
29
Popular Tags