Function wrap_with_nonce

Source
pub fn wrap_with_nonce(data: &JsValue) -> Result<JsValue, JsValue>
Expand description

You should protect scalar values and easy-to-guess lists by replacing them with an object that has an extra “nonce” property, which has enough entropy. List of all countries, cities in a country, streets in a city are all easy to enumerate for a brute-fore attack.

For example if you have a string that is a country, you can call this function like wrapJsonWithNonce("Germany") and get an object like the following:

{
    "nonce": "ukhFsI4a6vIZEDUOBRxJmLroPEQ8FQCjJwbI-Z7bEocGo",
    "value": "Germany"
}