-1

I used some apis to Encrypting & Decrypting a String in C# like : Encrypting & Decrypting a String in C# But Encrypting function return different results in different run times. How can i make it return same results in diffrents run time ? Thanks !

Community
  • 1
  • 1
tuancoi
  • 35
  • 6
  • If you've done the encryption correctly the run time will have no effect. Likely you are using a different secret w/ each program your are using for encryption/decryption. You must share the same secret with all programs that will encrypt/decrypt your data. – ScottS Jun 19 '16 at 17:35
  • If you refer to the answer with most up votes, then it produces different results each time as it uses random IV and salt each time - and this is not a bad thing .. – Ebbe M. Pedersen Jun 19 '16 at 17:36
  • 1
    Why do you want same outputs every time? The fact that they are different is [important security feature](https://en.wikipedia.org/wiki/Deterministic_encryption#Leakage) - long story short someone could draw assumptions about your plaintext just by comparing different ciphertexts – joozek Jun 19 '16 at 17:46

1 Answers1

1

How can i make it return same results in diffrents run time ?

I think you should rather use Hashing in such case. Cause hashing when done with the same secret salt key and using the same same hashing mechanism (like SHA HMACSHA, MD5) is guaranteed to generate the same hash key/signature.

Rahul
  • 76,197
  • 13
  • 71
  • 125