title: Where to store IV that is needed for decryption in Android app?
body: <p>Where should I store the IV (byte array) needed for AES decryption in my Android app? I've tried converting it to a string in Base64 and saving it to shared preferences, but kept getting a bad padding exception. I tried to change the padding, but it didn't work.</p>
  
  <p>I also saved the IV (byte array) to the keystore's provider and that worked, but while debugging in Visual Studio for Mac, the provider's content (in this case the IV) gets erased every time I run the app. The provider is still there but nothing is saved in the provider. Android's documentation says that "Each provider... is configured in each runtime it is installed in." Will this be an issue once the app is installed on an actual device?</p>
  
  <p>I am coding in c# in Visual Studio for Mac.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>this is my code using Base64 encoding:</p>
  
  <p>string ivString = Base64.EncodeToString(ivByteArray, Base64Flags.Default);</p>
  
  <p>byte[] decodedIV = Base64.Decode(ivString, Base64Flags.Default);</p>
  
  <p>when I print out the original byte array and the decoded byte array, they are exactly the same but I keep getting a bad padding exception</p>
  
  <p>I am using AES, CBC, and EncryptionPaddingPkcs7</p>