-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmd5.html
233 lines (225 loc) · 9.49 KB
/
md5.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
---
dl-file-prefix: "dd-md5-"
layout: "codelib-tplt"
group: lib
priority: 10
version: "1.1.1"
release-date: "2014-01-11"
platforms: ["Win32", "Win64"]
frameworks: ["RTL"]
compatibility: "Delphi 2009 & later"
title: "MD5 Message Digest Unit"
precis: "Implements the MD5 Message Digest Algorithm"
summary: "Object oriented implementation of the MD5 Message Digest Algorithm"
meta-title: "Comprehensive MD5 Calculation Unit for Delphi Pascal | Open Source | 32 & 64 bit"
meta-desc: "Delphi Pascal class that calculates MD5 hashes for various data types & files. Passes all tests specified in RFC 1321. Requires Delphi 2009 & later."
download-base-url: "https://sourceforge.net/projects/ddablib/files/md5/"
repo-url: "https://github.com/ddablib/md5"
docs-url: "https://github.com/delphidabbler/ddab-lib-docs/blob/master/Docs/MD5.md"
want-header-buttons: true
status: "current"
---
{% assign dl-file = page.dl-file-prefix | append: page.version | append: ".zip" %}
{% assign dl-url = page.download-base-url | append: dl-file %}
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Overview
</h2>
</div>
<div class="panel-body">
<p>
This unit contains an object-oriented implementation of the MD5 message digest algorithm.
</p>
<p>
A Delphi class named <var>TPJMD5</var> provides overloaded methods for calculating the MD5 of:
</p>
<ul>
<li>
Files.
</li>
<li>
Byte arrays.
</li>
<li>
Strings: Unicode, ANSI and short strings are all supported.
</li>
<li>
Streams.
</li>
<li>
Untyped data buffers (useful for getting the MD5 of ordinal values).
</li>
</ul>
<p>
Data types can be mixed and matched. Class methods provide quick shortcuts to taking the MD5 of a single file or single data item without having to explicitly create and free a <var>TPJMD5</var> instance.
</p>
<p>
There is also an "advanced" record, <var>TPJMD5Digest</var>, that encapsulutes a MD5 digest. Operator overloads for assigning digests to and from strings and byte arrays are provided. The digest can also be read in long words chunks.
</p>
<p>
The code was developed from scratch based on the algorithm presented in <a href="http://www.faqs.org/rfcs/rfc1321.html">RFC 1321</a>. Portions of the code are translated from the reference C code supplied in the RFC. However the code is <strong>not</strong> a literal translation into Pascal from the reference C code.
</p>
<p class="alert alert-info glyph">
The algorithm and reference code are copyright © 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.
</p>
<h3 data-toggle="collapse" data-target="#testing" class="collapsible collapsed">
Testing
</h3>
<div id="testing" class="collapse"> <!-- begin collapsible #testing section -->
<p>
<em>DUnit</em> tests for the unit are supplied in the download. The tests include all those specified in <a href="http://www.faqs.org/rfcs/rfc1321.html">RFC 1321</a>.
</p>
</div> <!-- /#testing -->
<h3 data-toggle="collapse" data-target="#rationale" class="collapsible collapsed">
Rationale
</h3>
<div id="rationale" class="collapse"> <!-- begin collapsible #rationale section -->
<p>
So why write this code?
</p>
<p>
Well, I'd been searching for an up-to-date implementation of the MD5 algorithm that met these criteria:
</p>
<ol class="wide">
<li>
No dependency on <code>.obj</code> files or DLLs. I wanted pure Pascal code.
</li>
<li>
Open source with a license compatible with the Mozilla Public License because I want to use it in an MPLd application of mine, so GPL-only code was ruled out.
</li>
<li>
Compiles and works with the Unicode Delphi Compilers.
</li>
<li>
Object oriented.
</li>
<li>
Easy to get an MD5 digest from all sorts of data without messing about converting it and playing around with contexts etc.
</li>
</ol>
<p>
I couldn't find anything that suited, so it seemed easier to start from scratch. After a couple of false starts, this unit is the result.
</p>
</div> <!-- /#rationale -->
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Get The Code
</h2>
</div>
<div class="panel-body">
<p>
You can download the latest version of the <em>{{page.title}}</em> directly from SourceForge as <code>{{ dl-file }}</code>.
</p>
<p class="text-center">
<a class="btn btn-primary" role="button" href="{{ dl-url }}" aria-label="Go to SourceForge and download latest version automatically">Download <span class="hidden-xs">release </span>v{{ page.version }}<span class="hidden-xs"> from SourceForge</span></a>
</p>
<p>
The <em>{{ page.title }}</em> source code is hosted in the <a href="{{ page.repo-url }}" aria-label="Link to the ddablib/md5 repository on GitHub"><code>ddablib/md5</code></a> GitHub repository. You can <code>git clone</code> or fork the repository as required.
</p>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Installation
</h2>
</div>
<div class="panel-body">
<p>
The <em>{{page.title}}</em>, documentation and test suite are supplied in a zip file. Before installing you need to extract all the files, preserving the directory structure. The following files will be extracted:
</p>
<ul class="list-group">
<li class="list-group-item">
<strong><code>PJMD5.pas</code></strong> – source code.
</li>
<li class="list-group-item">
<code>ReadMe.htm</code> – read-me file.
</li>
<li class="list-group-item">
<code>ChangeLog.txt</code> – project change log.
</li>
<li class="list-group-item">
<code>Documentation.URL</code> – short-cut to the unit's online documentation.
</li>
<li class="list-group-item">
<code>License.txt</code> – the project's license.
</li>
<li class="list-group-item">
<code>MPL-2.txt</code> – the Mozilla Public License v2.0.
</li>
<li class="list-group-item">
<code>MD5-Notice.txt</code> – MD5 algorithm licensing notice.
</li>
</ul>
<p>
In addition to the above files you will find the <em>DUnit</em> tests for <code>PJMD5.pas</code> in the <code>Test</code> sub-directory.
</p>
<p>
There are three possible ways to use the unit.
</p>
<ol class="wide">
<li>
The simplest way is to add <code>PJMD5.pas</code> to your projects as you need it.
</li>
<li>
To make the unit easier to re-use you can either copy it to a folder on your Delphi search path, or add the folder where you extracted the unit to the Delphi Search path. You then simply use the unit as required without needing to add it to your project.
</li>
<li>
For maximum portability you can add the unit to a Delphi 32 bit or 64 bit Windows package. If you need help doing this <a href="{{ site.data.core.install-to-ide-link }}" aria-title="see a tip on working with design time packages">see here</a>.
</li>
</ol>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
Documentation
</h2>
</div>
<div class="panel-body">
<p>
The <em>{{page.title}}</em> is comprehensively documented online <a href="{{ page.docs-url }}" aria-title="View the online documentation">here</a>
</p>
<p>
The project's change log can be viewed <a href="https://raw.githubusercontent.com/ddablib/md5/main/Docs/ChangeLog.txt" aria-title="View the change log in plain text">here</a>.
</p>
<p>
A read-me file (<code>ReadMe.htm</code>) is included in the project download.
</p>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title" id="feedback">
Feedback & Queries
</h2>
</div>
<div class="panel-body">
<p>
If you find any bugs or want to suggest a new feature please report them using the <em>{{page.title}}</em> <a href="https://github.com/ddablib/md5/issues">issue tracker</a>.
</p>
<p>
If you have created a bug fix or have implemented a new feature please open a pull request for it.
</p>
<p>
Should you have any queries about using the unit please read the <a href="{{ page.docs-url }}">documentation</a>. If you can't find an answer in the documentation then post a message in the <a href="https://github.com/orgs/ddablib/discussions">discussion group</a>.
</p>
</div>
</section>
<section class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
License
</h2>
</div>
<div class="panel-body">
<p>
<span class="fa fa-copyright fa-pull-left fa-3x"></span>
The <em>{{page.title}}</em> is open source. It is copyright © 2010-2014 by <a href="https://en.gravatar.com/delphidabbler" aria-label="Peter Johnson's Gravatar account">Peter Johnson</a>. The source code is made available under the terms of the <a href="https://www.mozilla.org/MPL/2.0/" aria-label="Mozilla Public License v2.0 on mozilla.org">Mozilla Public License v2.0</a>. All relevant trademarks are acknowledged.
</p>
</div>
</section>