Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why have a dependency on okio? #11

Closed
mirraj2 opened this issue Nov 7, 2018 · 2 comments
Closed

Why have a dependency on okio? #11

mirraj2 opened this issue Nov 7, 2018 · 2 comments

Comments

@mirraj2
Copy link

mirraj2 commented Nov 7, 2018

You literally only use it in one place and it is EASILY replaced with a ByteArrayOutputStream.

I rewrote your the last part of your encrypt() method to not use any dependencies:

ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {
      output.write(cipher.getIV());
      output.write(encryptedBytes);

      // compute the MAC if needed and append the MAC (IV || CIPHER || MAC)
      if (context.getMacAlgorithm() != AliceContext.MacAlgorithm.NONE) {
        output.write(getMac(context.getMacAlgorithm(), password).doFinal(encryptedBytes));
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    return output.toByteArray();
@rockaport
Copy link
Owner

Yep, it's unnecessary. The idea at the time was to integrate okio sources and sinks, but eventually that got tossed aside. Submit a PR and I'll get it merged.

@rockaport
Copy link
Owner

Fixed in v0.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants