Source Code Cross Referenced for GeneralDigest.java in  » Database-JDBC-Connection-Pool » jTDS » net » sourceforge » jtds » util » 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 » Database JDBC Connection Pool » jTDS » net.sourceforge.jtds.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * Copyright (c) 2000 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
003:         * Permission is hereby granted, free of charge, to any person obtaining a
004:         * copy of this software and associated documentation files (the "Software"),
005:         * to deal in the Software without restriction, including without limitation
006:         * the rights to use, copy, modify, merge, publish, distribute, sublicense,
007:         * and/or sell copies of the Software, and to permit persons to whom the
008:         * Software is furnished to do so, subject to the following conditions:
009:         *
010:         * The above copyright notice and this permission notice shall be included
011:         * in all copies or substantial portions of the Software.
012:         *
013:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
014:         * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
015:         * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
016:         * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
017:         * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
018:         * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
019:         * USE OR OTHER DEALINGS IN THE SOFTWARE.
020:         ******************************************************************************/package net.sourceforge.jtds.util;
021:
022:        /**
023:         * base implementation of MD4 family style digest as outlined in
024:         * "Handbook of Applied Cryptography", pages 344 - 347.
025:         *
026:         * @version $Id: GeneralDigest.java,v 1.2 2004/06/27 17:00:55 bheineman Exp $
027:         */
028:        public abstract class GeneralDigest
029:        //    implements Digest - mdb: we don't care about this interface
030:        {
031:            private byte[] xBuf;
032:            private int xBufOff;
033:
034:            private long byteCount;
035:
036:            /**
037:             * Standard constructor
038:             */
039:            protected GeneralDigest() {
040:                xBuf = new byte[4];
041:                xBufOff = 0;
042:            }
043:
044:            /**
045:             * Copy constructor.  We are using copy constructors in place
046:             * of the Object.clone() interface as this interface is not
047:             * supported by J2ME.
048:             */
049:            protected GeneralDigest(GeneralDigest t) {
050:                xBuf = new byte[t.xBuf.length];
051:                System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length);
052:
053:                xBufOff = t.xBufOff;
054:                byteCount = t.byteCount;
055:            }
056:
057:            public void update(byte in) {
058:                xBuf[xBufOff++] = in;
059:
060:                if (xBufOff == xBuf.length) {
061:                    processWord(xBuf, 0);
062:                    xBufOff = 0;
063:                }
064:
065:                byteCount++;
066:            }
067:
068:            public void update(byte[] in, int inOff, int len) {
069:                //
070:                // fill the current word
071:                //
072:                while ((xBufOff != 0) && (len > 0)) {
073:                    update(in[inOff]);
074:
075:                    inOff++;
076:                    len--;
077:                }
078:
079:                //
080:                // process whole words.
081:                //
082:                while (len > xBuf.length) {
083:                    processWord(in, inOff);
084:
085:                    inOff += xBuf.length;
086:                    len -= xBuf.length;
087:                    byteCount += xBuf.length;
088:                }
089:
090:                //
091:                // load in the remainder.
092:                //
093:                while (len > 0) {
094:                    update(in[inOff]);
095:
096:                    inOff++;
097:                    len--;
098:                }
099:            }
100:
101:            public void finish() {
102:                long bitLength = (byteCount << 3);
103:
104:                //
105:                // add the pad bytes.
106:                //
107:                update((byte) 128);
108:
109:                while (xBufOff != 0) {
110:                    update((byte) 0);
111:                }
112:
113:                processLength(bitLength);
114:
115:                processBlock();
116:            }
117:
118:            public void reset() {
119:                byteCount = 0;
120:
121:                xBufOff = 0;
122:                for (int i = 0; i < xBuf.length; i++) {
123:                    xBuf[i] = 0;
124:                }
125:            }
126:
127:            protected abstract void processWord(byte[] in, int inOff);
128:
129:            protected abstract void processLength(long bitLength);
130:
131:            protected abstract void processBlock();
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.