Skip to content

Instantly share code, notes, and snippets.

@maraoz
Created April 15, 2014 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maraoz/10776497 to your computer and use it in GitHub Desktop.
Save maraoz/10776497 to your computer and use it in GitHub Desktop.
is this secure from browser extensions inspecting the secret value?
var Hasher = (function(){
var secret = 42;
var Hasher = function() {
};
Hasher.prototype.setSecret = function(s) {
secret = s;
};
Hasher.prototype.hash = function(x) {
return secret * x;
};
return Hasher;
})();
var h = new Hasher();
h.setSecret(321);
console.log(h.hash(7)); // prints 2247
console.log(h.secret); // prints undefined
@maraoz
Copy link
Author

maraoz commented Apr 15, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment