Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

API Request : encrypt(byte[] plainText, byte[] passwordOrKey) //return encrypted text #19

Closed
MufriA opened this issue Feb 13, 2014 · 2 comments

Comments

@MufriA
Copy link

MufriA commented Feb 13, 2014

Since we API's like below

public byte[] encrypt(byte[] plainText);
public byte[] decrypt(byte[] cipherText);

can we have

public byte[] encrypt(byte[] plainText, byte[] passwordOrKey);
public byte[] decrypt(byte[] cipherText, byte[] passwordOrKey);

which uses given password rather than from SharedPreference, I understand I can implement Custom KeyChain, however these API's are much simpler for the cases where encryption is based on inputs from user.

@siyengar
Copy link
Contributor

I thought about this and I understand why this makes it simpler for your use case. However I think this API breaks the contract of Crypto and may make it more confusing to use for others. That is you pass in a keychain from which Crypto gets a key, but then the key is overriden by this API. It would also cause an explosion of methods in the case where if we have to do this for MACs as well. It would also prevents us from changing the algorithm in the future because some algorithms might supply more than 1 key as a parameter.

Hope this makes sense and represents compelling reasons not to add this API.

@siyengar
Copy link
Contributor

I'm closing the issue for now, feel free to reopen if you have additional comments.

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

No branches or pull requests

2 participants