Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foxcapades/lib-jvm-md5
Convenience wrapper for generating MD5 hashes.
https://github.com/foxcapades/lib-jvm-md5
checksum hash library md5
Last synced: 5 days ago
JSON representation
Convenience wrapper for generating MD5 hashes.
- Host: GitHub
- URL: https://github.com/foxcapades/lib-jvm-md5
- Owner: Foxcapades
- License: mit
- Created: 2022-10-13T14:20:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-16T20:38:00.000Z (almost 2 years ago)
- Last Synced: 2024-10-17T01:19:00.664Z (20 days ago)
- Topics: checksum, hash, library, md5
- Language: Kotlin
- Homepage:
- Size: 275 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.adoc
- License: license
Awesome Lists containing this project
README
= MD5
:source-highlighter: pygments
:lib-version: 1.0.1image:https://img.shields.io/github/license/foxcapades/lib-jvm-md5[GitHub]
image:https://img.shields.io/badge/docs-dokka-green[link="https://foxcapades.github.io/lib-jvm-md5/"]
image:https://img.shields.io/maven-central/v/io.foxcapades.lib/md5[Maven Central, link="https://search.maven.org/artifact/io.foxcapades.lib/md5"]Convenience wrapper around using the JDK `MessageDigest` type to generate MD5
checksums.== Import
.build.gradle.kts
[source, kotlin, subs="verbatim,attributes"]
----
implementation("io.foxcapades.lib:md5:{lib-version}")
----.build.gradle
[source, groovy, subs="verbatim,attributes"]
----
implementation "io.foxcapades.lib:md5:{lib-version}"
----.pom.xml
[source, xml, subs="verbatim,attributes"]
----
io.foxcapades.lib
md5
{lib-version}
----== Examples
.Kotlin
[source, kotlin]
----
import io.foxcapades.lib.md5.MD5
import java.io.Filefun main() {
// Hashing the contents of a file
val fileHash = MD5.hash(File("readme.adoc"))// Hashing a plain string
val stringHash = MD5.hash("some text")// Hashing a reader stream
val readerHash = MD5.hash("some text".reader())// Hashing an InputStream
val streamHash = MD5.hash("some text".byteInputStream())// Printing a hash as a lowercase hex string
println(fileHash.toHexString(true))// Printing a hash as an uppercase hex string
println(stringHash.toHexString())// Getting the raw bytes of a hash
readerHash.bytes
}
----.Java
[source, java]
----
import io.foxcapades.lib.md5.MD5;
import io.foxcapades.lib.md5.MD5Hash;import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.StringReader;public class Example {
public static void main(String[] args) {
// Hashing the contents of a file
MD5Hash fileHash = MD5.hash(new File("readme.adoc"));// Hashing a plain string
MD5Hash stringHash = MD5.hash("some text");// Hashing a reader stream
MD5Hash readerHash = MD5.hash(new StringReader("some text"));// Hashing an InputStream
MD5Hash streamHash = MD5.hash(new ByteArrayInputStream("some text".getBytes()));// Printing a hash as a lowercase hex string
System.out.println(fileHash.toHexString(true));// Printing a hash as an uppercase hex string
System.out.println(stringHash.toHexString());// Getting the raw bytes of a hash
readerHash.getBytes();
}
}
----