Source Code Cross Referenced for MessageDigest.java in  » Portal » Open-Portal » com » sun » portal » ksecurity » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.ksecurity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)MessageDigest.java	1.10 02/07/24 @(#)
003:         *
004:         * Copyright (c) 2000-2001 Sun Microsystems, Inc.  All rights reserved.
005:         * PROPRIETARY/CONFIDENTIAL
006:         * Use is subject to license terms.
007:         */
008:
009:        package com.sun.portal.ksecurity;
010:
011:        /**
012:         * Implements an abstract class that generalizes all message digests.
013:         * It is modelled after javacard.security.MessageDigest. This version
014:         * of the implementation only supports ALG_MD5 (which produces a 16-byte
015:         * hash as described in RFC 2313) and ALG_SHA (which produces a 20-byte
016:         * hash using NIST's SHA1 algorithm). MD2, a predecessor to MD5, is not
017:         * supported.
018:         */
019:        public abstract class MessageDigest {
020:            /** Indicates the MD5 message digest algorithm. */
021:            public static final byte ALG_MD5 = 1;
022:            /** Indicates the SHA message digest algorithm. */
023:            public static final byte ALG_SHA = 2;
024:            /** Indicates the MD2 message digest algorithm. */
025:            public static final byte ALG_MD2 = 3;
026:
027:            /** Protected constructor. */
028:            protected MessageDigest() {
029:            }
030:
031:            /**
032:             * Creates a MessageDigest object instance of the specified
033:             * algorithm. The second parameter is ignored for now -- it is
034:             * here only for compatibility with the javacard.security.MessageDigest
035:             * class. 
036:             * @param alg the desired message digest algorithm, e.g. ALG_MD5
037:             * @param ext ignored
038:             * @return a MessageDigest object instance of the requested algorithm
039:             * @exception CryptoException with NO_SUCH_ALGORITHM reason code if the
040:             * requested algorithm is not supported.
041:             */
042:            public static MessageDigest getInstance(byte alg, boolean ext)
043:                    throws CryptoException {
044:                switch (alg) {
045:                case ALG_MD5:
046:                    return new MD5();
047:                case ALG_SHA:
048:                    return new SHA();
049:                case ALG_MD2:
050:                    return new MD2();
051:                default:
052:                    throw new CryptoException(CryptoException.NO_SUCH_ALGORITHM);
053:                }
054:            }
055:
056:            /** 
057:             * Gets the message digest algorithm.
058:             * @return algorithm implemented by this MessageDigest object
059:             */
060:            public abstract byte getAlgorithm();
061:
062:            /** 
063:             * Gets the length (in bytes) of the hash.
064:             * @return byte-length of the hash produced by this object
065:             */
066:            public abstract byte getLength();
067:
068:            /** 
069:             * Generates a hash of all/last input data. Completes and returns the
070:             * hash compuatation after performing final operations such as padding.
071:             * The MessageDigest object is reset after this call. 
072:             * @param inBuf input buffer of data to be hashed
073:             * @param inOff offset within inBuf where input data begins
074:             * @param inLen length (in bytes) of data to be hashed
075:             * @param outBuf output buffer where the hash should be placed
076:             * @param outOff offset within outBuf where the resulting hash begins
077:             * @return number of bytes of hash left in outBuf
078:             */
079:            public abstract short doFinal(byte[] inBuf, int inOff, int inLen,
080:                    byte[] outBuf, int outOff);
081:
082:            /**
083:             * Accumulates a hash of the input data. This method is useful when
084:             * the input data to be hashed is not available in one byte array. 
085:             * @param inBuf input buffer of data to be hashed
086:             * @param inOff offset within inBuf where input data begins
087:             * @param inLen length (in bytes) of data to be hashed
088:             * @see #doFinal(byte[], int, int, byte[], int)
089:             */
090:            public abstract void update(byte[] inBuf, int inOff, int inLen);
091:
092:            /** 
093:             * Resets the MessageDigest to the initial state for further use.
094:             */
095:            public abstract void reset();
096:
097:            /** 
098:             * Clones the MessageDigest object.
099:             * @return a clone of this object
100:             */
101:            public abstract Object clone();
102:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.