(PureBasic) Obfuscate String
Demonstrates how to obfuscate and unobfuscate a string.
IncludeFile "CkStringBuilder.pb"
Procedure ChilkatExample()
sb.i = CkStringBuilder::ckCreate()
If sb.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
s.s = "Hello World!"
CkStringBuilder::ckAppend(sb,s)
Debug CkStringBuilder::ckGetAsString(sb)
; Output is "Hello World!";
; Obfuscate the string.
; This is NOT encryption. It's just a simple obfuscation.
CkStringBuilder::ckObfuscate(sb)
Debug CkStringBuilder::ckGetAsString(sb)
; Output is 2GsgGhbSQVyG8Vb9
; -------------------------
; Unobfuscate.
sb2.i = CkStringBuilder::ckCreate()
If sb2.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
s2.s = "2GsgGhbSQVyG8Vb9"
CkStringBuilder::ckAppend(sb2,s2)
CkStringBuilder::ckUnobfuscate(sb2)
Debug CkStringBuilder::ckGetAsString(sb2)
; Output is "Hello World!";
CkStringBuilder::ckDispose(sb)
CkStringBuilder::ckDispose(sb2)
ProcedureReturn
EndProcedure
|