Custom JSP tag. Tag provides the functionality of a message
digest algorithm, such as MD5 or SHA. Message digests are secure one-way hash functions.
Message should be provided as a body of this tag or as a parameter. By default tag automatically encodes
calculated value (base64 encoding).
For example:
<!-- data as a body -->
<%@ taglib uri="taglib.tld" prefix="calc" %>
<calc:Digest algorithm="MD5" id="A">
... your data
</calc:Digest>
Hash code is: <%=A%>
<!-- data as a parameter -->
<calc:Digest algorithm="SHA-1" data="qwerty"/>
Tags are:
Digest
Calculates message digest. Parameters are:
1) algorithm Hash algorithm. Possible values are MD5 or SHA-1
2) data Optional parameter. Describes your data (if you
did not set them as a body of this tag).
3) encode Optional parameter. Possible values are true or false.
If this value is true than tag will encode calculated value. Default value is true.
4) id page scope variable for generated hash. Without
this parameter hash string will be printed. Type for this object depends on the attribute encode.
If encode is true than type is java.lang.String otherwise it is
java.lang.Object and you can cast it to byte[].
DigestFile
Calculates digest for file. Parameters are:
1) algorithm Hash algorithm. Possible values are MD5 or SHA-1
2) data Optional parameter. Describes your file (if you
did not set it as a body of this tag).
3) encode Optional parameter. Possible values are true or false.
If this value is true than tag will encode calculated value. Default value is true.
4) id page scope variable for generated hash. Without
this parameter hash string will be printed. Type for this object depends on the attribute encode.
If encode is true than type is java.lang.String otherwise it is
java.lang.Object and you can cast it to byte[].
for downloading:
Library: md5tag.jar Description: taglib.tld
© Coldbeans
Comments?
See also Coldtags suite - the largest collection of custom JSP tags.
|