Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

com.github.glusk:caesar

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.glusk:caesar

An object-oriented approach to cryptography in Java.

  • 0.8.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Caesar

Logo

Build Status Build status Codacy Badge Coverage Status

Maven Central javadoc

LoC Hits-of-Code

An object-oriented approach to cryptography in Java.


Motivation

This project aims to replace/wrap the following JDK APIs: MessageDigest, Mac and Cipher.

cactoos-crypto is a direct alternative to this project.

Hashing

In order to start using Caesar's hashing utilities you first have to wrap a MessageDigest instance inside a new ImmutableMessageDigest object:

ImmutableMessageDigest imd =
    new ImmutableMessageDigest(
        MessageDigest.getInstance(/* ... */)
    );

Once you obtain an ImmutableMessageDigest instance, you can perform the hashing:

// ImmutableMessageDigest imd = ...
Bytes result = new Hash(imd, new PlainText("password123"));

You can also use ImmutableMessageDigest's fluid API:

// ImmutableMessageDigest imd = ...
byte[] result = imd.update(new PlainText("password123")).digest();

Embedded hashes

You can pass the result of one hashing operation as an argument to another.

Suppose we wanted to compute the following hash:

H(H(b1), b2, b3)

This is how it would be done with Caesar:

// byte[] b1 = ...
// byte[] b2 = ...
// byte[] b3 = ...
// ImmutableMessageDigest imd = ...

Bytes result = 
    new Hash(
        imd,
        new Hash(
            imd,
            () -> b1
        ),
        () -> b2,
        () -> b3
    );

HMAC

This is how you compute HMAC("Key", "Message") with Caesar, using the SHA-256 hash function:

Bytes hmac =
    new Hmac(
        new ImmutableMessageDigest(
            MessageDigest.getInstance("SHA-256")
        ),
        new PlainText("Key"),
        new PlainText("Message")
    );

Releases

Use the release script with the following arguments:

  1. release - the next release version

  2. snapshot - the next snapshot version

  3. dryRun (optional) - if set to true, the changes will not be pushed to the remote repository

Example:

./release.sh 0.1.1 0.1.2-SNAPSHOT

Logo icon made by Pixelmeetup from www.flaticon.com

FAQs

Package last updated on 18 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc