[removed] hiding contents of key

前端 未结 8 1341
梦谈多话
梦谈多话 2020-12-22 14:04

In the code below I want to hide the contents of the key(speaker) key being viewed by browser console.

var App_Version         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 14:55

    There is no way in Javascript to hide the contents of a variable without unsetting the variable, which is of no use to you if you need to reference whatever that value was later. A few options to choose from, depending on exactly what you need would be this:

    Hashing the value

    You could has the value with MD5 or SHA. This way the user doesn't know what the value is but you can still send it off to the server and store it that way

    Store the value on the server

    You could store the value on the server and reference it with some sort of key. That way the user never sees the actual value, they are just checking the server to see if the value they have matches what the server has.

    If this is a password that is being generated and we never want the user to see it, your best bet is to handle all of that on there server, this way there is no chance the user will ever even have the value on the client side.

提交回复
热议问题