JavaScript
JavaScript
Obfuscate String
Demonstrates how to obfuscate and unobfuscate a string.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var success = false;
var sb = new CkStringBuilder();
var s = "Hello World!";
sb.Append(s);
console.log(sb.GetAsString());
// Output is "Hello World!";
// Obfuscate the string.
// This is NOT encryption. It's just a simple obfuscation.
sb.Obfuscate();
console.log(sb.GetAsString());
// Output is 2GsgGhbSQVyG8Vb9
// -------------------------
// Unobfuscate.
var sb2 = new CkStringBuilder();
var s2 = "2GsgGhbSQVyG8Vb9";
sb2.Append(s2);
sb2.Unobfuscate();
console.log(sb2.GetAsString());
// Output is "Hello World!";