In an existing web application project, there is a need to prevent raw ids being supplied to front end. Like following html:
<select name="InvoiceId">
<option value="1">Bill_1</option>
<option value="2">Bill_2</option>
</select>
to
<select name="InvoiceId">
<option value="encryptedString1">Bill_1</option>
<option value="encryptedString2">Bill_2</option>
</select>
Apart from above, there would be hidden input fields, attributes, etc. with sensitive ids. And they are being populated by controller's action returning JsonResult, ViewResult, etc.
Purpose is to secure the raw private ids being seen in the front end html source, and finally to make the change of front end ids useless(as upon decryption altered ids will be random gibberish).
For decryption one option would be to use model binder in MVC pipeline which would read the value and check if this is encrypted(perhaps by checking if it starts by some std string like BCrypt) and then decrypt, helping to not make any code change for decryption throughout the application.
Like so if anyone can suggest a way to implement encryption as a part of the application pipeline(perhaps by result filter?), so that developers are also forced to encrypt any property carrying sensitive data(perhaps which are marked with a custom attribute, like 'SensitiveInfo')
Key for encryption/decryption is also in question, perhaps which will be logged in user's sessionid with a random salt. And algorithm which will be fast enough.
Can someone suggest best way to implement this in existing web application?
Please note that application stack is .net MVC 5, JavaScript/jQuery, Dapper.