Skip to content

Instantly share code, notes, and snippets.

Yaroslav Surilov zhibirc

Block or report user

Report or block zhibirc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zhibirc
zhibirc / protector.js
Last active Oct 24, 2018
Protect API methods or arbitrary functions from introspection
View protector.js
/* Aim:
"function <function name>() {
[native code]
}"
*/
function protect ( fn ) {
fn.toString = fn.toLocaleString = fn.toSource = function () {
return 'function ' + fn.name + '() { [native code] }';
};
@zhibirc
zhibirc / gist:db0baa7ef3f4a7e564a19208ebae9c86
Last active Jul 7, 2017
Protection of the function code from inspection
View gist:db0baa7ef3f4a7e564a19208ebae9c86
// basic implementation
function protect ( fn ) {
fn.toString = fn.toLocaleString = fn.toSource = function () {
return 'function ' + fn.name + '() { [native code] }';
};
}
// but indirect call still available, so fix it
var protect = (function () {
// function can be reassign with different name, so use functions itself instead of string names
You can’t perform that action at this time.