can anyone tell me how should i go about hiding messages in whitespaces in the end of a text

for example
| = whitespace

hell my name is bob||
i work at home ||||

Recommended Answers

All 2 Replies

I do not understand what you are after.

Something like this will do:

def hide_word(word):
    """hide word as whitespace like tabs"""
    temps = ""
    tab = '\t'
    new_line = '\n'
    for letter in word:
        # 'A' would be 1 tab, 'B' 2 tabs etc.
        temps += tab * (ord(letter) - 64) + new_line
    return temps


text = "My name is "
hide = "Bob"

new_text = text + hide_word(hide)


# test
print('-'*60)
print(new_text)
print('-'*60)
# unhide
nt = 0
temps = ""
for c in new_text:
    if c == '\t':
        #print('|')
        nt += 1
    elif c == '\n':
        temps += chr(nt + 64)
        nt = 0
    else:
        temps += c
        nt = 0

print(temps)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.