On Fri, 6 Mar 2009, Luis Krause Mantilla wrote:
> Are there any docs on how #pragma TEXTHIDDEN(0|1) works?
> What's the overhead, pros/cons, etc and usefulness of this feature?

     It's a very simple XOR mask for text strings. You can write some
text which will not be visible to "mortal users" with standard tools
like EDIT or NOTEPAD. Any hacker will be able to read anyway (it will,
in any way you try to hide), but at least it will not be to the most
common user.

    // It's not the safest password...
    #pragma TEXTHIDDEN( 1 )
       IF cUser == "ME" .AND. cPassword == "SECRET"
          Login()
       ENDIF
    #pragma TEXTHIDDEN( 0 )

    #pragma TEXTHIDDEN( 1 )
       @ y,x SAY "I'm the author. Please don't change my name with yours."
    #pragma TEXTHIDDEN( 0 )

    DO WHILE .T.
       ACCEPT "Which one is the best xBase compiler? " TO cCompiler
    #pragma TEXTHIDDEN( 1 )
       IF UPPER( cCompiler ) == "XHARBOUR"
          ? "Yes! xHarbour is the best!"
    #pragma TEXTHIDDEN( 0 )
          EXIT
       ELSE
          ? "Incorrect answer! Try again."
       ENDIF
    ENDDO

It's slower than a "regular" strings, because it requires to allocate
a new memory block and XOR all characters on the string, but it affects
only static-string operations.

Atte.
  Vic

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
xHarbour-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to