Skip to content

Instantly share code, notes, and snippets.

View olastor's full-sized avatar

Sebastian olastor

  • Munich
  • 06:03 (UTC +02:00)
View GitHub Profile
@olastor
olastor / obfuscate.js
Last active January 29, 2025 00:25
Simple algorithm to quickly obfuscate a string in javascript.
/**
* Obfuscate a plaintext string with a simple rotation algorithm similar to
* the rot13 cipher.
* @param {[type]} key rotation index between 0 and n
* @param {Number} n maximum char that will be affected by the algorithm
* @return {[type]} obfuscated string
*/
String.prototype.obfs = function(key, n = 126) {
// return String itself if the given parameters are invalid
if (!(typeof(key) === 'number' && key % 1 === 0)