Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
/ cactoos-crypto Public archive

Crypto extensions for Cactoos library

License

Notifications You must be signed in to change notification settings

g4s8/cactoos-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WARNING

It was an experiment repository, it contains POC library code. It's not producation ready. It'll be not supported.


cactoos-crypto

EO principles respected here Managed by Zerocracy DevOps By Rultor.com

Bintray Build Status PDD status License Test Coverage

Cryptography extensions for Cactoos library.

Cipher as input/output

To encrypt/decrypt an input:

final Scalar<Cipher> cipher = new CipherFrom(
    "AES/CBC/PKCS5Padding",
    new CipherSpec(key, iv)
);
final Input encrypted = new CryptoInput.Enc(
  new InputOf(file),
  cipher
);
final Input decrypted = new CryptoInput.Dec(
  encrypted,
  cipher
);

To encrypt/decrypt an output:

final Scalar<Cipher> cipher = new CipherFrom(
    "AES/CBC/PKCS5Padding",
    new CipherSpec(key, iv)
);
final Output decrypting = new CryptoOutput.Dec(
  new OutputTo(file),
  cipher
);
final Output encrypting = new CryptoOutput.Enc(
  decrypting,
  cipher
);

MAC (Message Authentication Code) as Bytes:

To compute MAC of input:

final Bytes hmac = new MacOf(
  new InputOf(file),
  new MacFrom(
    "HmacSHA256",
    new MacSpec(key)
  )
);

MessageDigest as Bytes:

To compute message-digest of input:

final Bytes digest = new DigestOf(
  new InputOf(file),
  new DigestFrom("SHA-256")
);

Install

mvn:

<dependency>
  <groupId>com.g4s8</groupId>
  <artifactId>cryptocactoos</artifactId>
</dependency>

gradle:

  "com.g4s8:cryptocactoos:<vesion>"

Releases

No releases published

Packages

No packages published

Languages