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

problem with decrypting String cipher #99

Open
KadamMangesh opened this issue Dec 15, 2015 · 1 comment
Open

problem with decrypting String cipher #99

KadamMangesh opened this issue Dec 15, 2015 · 1 comment

Comments

@KadamMangesh
Copy link

Hi,
I am generating cipher for my token and CVV then saving both in sharedPref. Next time for any token am generating again cipher. Checking if that cipher exists in sharedPref. If it exists I am reading the CVV cipher against this token cipher. Later am trying to decrypt this CVV cipher. But it seems everytime I try to generate cipher for same String, am getting different cipher. Can I have the same cipher for given String?

@helios175
Copy link
Contributor

Back from vacations!

Hi, I'm not sure if I follow. Maybe a little code example should help me understand.

Let me see if I got your question: you are encrypting twice the same plain data, and then you get different outputs each time, right?

That is correct. The resulting cipher data is result (besides the algorithm used of course), the key and the initialization vector (IV). The IV is randomly generated for each encryption. That is important because an attacker cannot infer any information about the key by trying different specially crafted data. Failing to use strong random IV's is a vulnerability.

https://en.wikipedia.org/wiki/Initialization_vector

I'm assuming that the encryption key is the same. If you are using the provided SharedPrefsKeyChain it should be the case as it generates a random key the first time, and from then on, uses it.

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