Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A sweet task - hiding a text. 5

Status
Not open for further replies.

german12

Programmer
Joined
Nov 12, 2001
Messages
563
Location
DE
Yesterday my friend received a message containing this:

aivmgserhctlffwveethatesdehgria
bleybelwiaoeooeetwjonnlwivtheln
cordudlisufarrwrheuddiwereaysyd
dvyatoifcstsymiberneicieerloodt
eemrpnteoerwoelereeinettmytuhri
fyulloyauaoeualtalosthhbbnhweur
gocietosllulannosanlhoteeiohane
huhnatutdoblsdegwsraathdrguevkd.

I asked me whether he should throw it away.
But I said, he should not do, as there could be a
hidden message included in that text.

2 questions:

a)Can you read the contents?
b)How in the hell can that be programmed with a small
VFP-Program - and: Is that not a sweet task?
All messages like this you will receive are readable -
but only for you.... *gggg

Who answers first?

If nobody can, I will publish he the contents of the
letter, but have not yet found an easy program - a VFP program to place a text on paper so that only you can read it easily.



Regards

Klaus

Peace worldwide - it starts here...
 

Decripting data is never a "sweet task" and rarely a "real life situation".

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike, what is real life for you?

Of course I can always take my laptop with me to remember some figures or information - but to wear a simple sheet of paper where I excactly know how to find (and direct read) what I want to know - but not easy for others - do you not think this happens every day? A secret telephone number, a certain sentence, some results from the balance-sheet, a love letter....etc.

Data encryption on a sheet of paper - not real life?

Of course data encryption ist perhaps to high but this "semi-encryption" seemed interesting to me.

Take it with humour.

Regards
Klaus




Peace worldwide - it starts here...
 
Data encryption on a sheet of paper - not real life?

In all my years of programming experience, this king of request never came up. I was never requested to encrypt or decrypt anything.
Although I have seen puzzle books that contain these type of puzzles, I never interrested me. So I guess I only spoke for myself.
Perhaps someone else will partake in your riddle.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
a)Can you read the contents?
NO!
b)How in the hell can that be programmed with a small VFP-Program
reasonably easily!!
Is that not a sweet task? All messages like this you will receive are readable - but only for you....
Not really, and like Mike, other than for a specific job, such as we use for personal information encryption, I dont really see the point.

The problem with any code encryption, especially using a computer is, it MUST have a logical key to convert it from decrypt to encrypt and back again. Fine in an embedded app like ours where we, and only we, hold the key but to be usable generally, as the Germans found out with their wartime Enigma codeing, you have to give the key to the recipiant for it to be any use. Once a third party has the key the point of encrypt/decrypt becomes useless! After all, wasn't the worlds FIRST computer invented precisely for this task!!!?

Bob Palmer
The most common solution is H2O!
 
Bob, I know that interesting story of ENIGMA, and you are of course right with all what you said about the ownership of the
key.

Now, as I promised - here is the solution first - and you do not need a key to read the contents: Just forget the first column and read beginning with second one VERTICALLY.
And again continue reading the 3rd. column reading VERTICALLY.
and so on.

The first column is just the letter lines marked with A,B, C... and they are only for irritation.

And only that knowledge is necessary, but as one will not
know what is behind that complex of letters it will be
hard to read over the shoulder, what I want to say is that
even printed paper can hide a secret message.

But how to divide a long string into pieces which can
be VERTICALLY be printed but only as long as e.g. a sheet
of paper ist e.g 60 lines.



All I know is that for the coding you will need
a file where you receive the message with.
Then you will need the FILETOSTR function to make a long
string from it.
Then you will have to make portions of that string which
are not longer then the vertical height of a piece of paper.
At the same time you have to watch the width of your paper.

So I think it is not very easy....

But how have the correct loops to be programmed - that is what I wanted to find out.

i v m g s e r h c t l f f w v e e t h a t e s d e h g r i a
l e y b e l w i a o e o o e e t w j o n n l w i v t h e l n
o r d u d l i s u f a r r w r h e u d d i w e r e a y s y d
v y a t o i f c s t s y m i b e r n e i c i e e r l o o d t
e m r p n t e o e r w o e l e r e e i n e t t m y t u h r i
y u l l o y a u a o e u a l t a l o s t h h b b n h w e u r
o c i e t o s l l u l a n n o s a n l h o t e e i o h a n e
u h n a t u t d o b l s d e g w s r a a t h d r g u e v k d.


HERE IS THE HIDDEN TEXT:

I love you very much my darling but please do not tell it your wife as this could cause a lot of trouble as well for you as for me and we will never be together as we were last june on rhode island in that nice hotel with the sweet bedd*
i rember* every night although you wheree so heavily drunk and tired.

*typing errors (my bad english)

This is the text which should lead to the "encrypted" message where the first column is just A...to H, (depending
on the number of lines.)

I dont think that this is as easy as you said.

Regards
Klaus



Peace worldwide - it starts here...
 
Very silly, but I will indulge you.

Code:
lcString=[aivmgserhctlffwveethatesdehgria]+CHR(13)+CHR(10)
lcString=lcString+[bleybelwiaoeooeetwjonnlwivtheln]+CHR(13)+CHR(10)
lcString=lcString+[cordudlisufarrwrheuddiwereaysyd]+CHR(13)+CHR(10)
lcString=lcString+[dvyatoifcstsymiberneicieerloodt]+CHR(13)+CHR(10)
lcString=lcString+[eemrpnteoerwoelereeinettmytuhri]+CHR(13)+CHR(10)
lcString=lcString+[fyulloyauaoeualtalosthhbbnhweur]+CHR(13)+CHR(10)
lcString=lcString+[gocietosllulannosanlhoteeiohane]+CHR(13)+CHR(10)
lcString=lcString+[huhnatutdoblsdegwsraathdrguevkd.]+CHR(13)+CHR(10)

lnStrLen=AT(CHR(13),lcString)
lcResult=[]
FOR lnLen = 2 TO lnStrLen
 FOR lnLines = 1 TO ALINES(laLines,lcstring)
  lcResult=lcResult+SUBSTR(laLines(lnLines),lnLen,1)
 ENDFOR
ENDFOR

?lcResult
 
Baltman,
thanks for your good idea - and a first approach.

It is easy (for you - not for me) to do this with a given string and therefore it could have been hard-coded, but what I wanted was that the string was built automatically from a any textfile and such a file varies of course - and additonally the string is typed in columns instead of a long
row as your prog does.

So for the next message coming in your program will not work
as it is not written in general coding, right?
Next time you would have to type again into the program what you already saw in the message, and that is in-effective.

I know it sounds silly - but it remains difficult, so far no one will believe it.

Apart from that - a star for you!



Peace worldwide - it starts here...
 
Hi Klaus,

well, what baltman gave you is the decoder. You may easily do this for any encrypted text by replacing the first part with lcString = filetostr(getfile()), if you have stored the encrypted message to a file.

And encrypting a normal text is almost the same, isn't it? Just take each Nth letter from the original string (remove spaces first) and put it in a line, starting with offsets 0 to N-1 (or 1 to N) you get N lines, one for each offset.

Code:
#define cnLines 3
#define ccDestinationfile "c:\temp\encrypted.txt"
lcText = "Hello, World!" && lcText = filetostr(getfile())
lcText = chrtran(lcText," ","") && maybe remove other chars
lcText = lower(lcText)

local array lcLines[cnLines]
strtofile("",ccDestinationfile,.f.)
For lnOffset = 1 to cnLines
   lcLines[lnOffset]=""
   lnPosition = lnOffset
   Do While lnPosition <= Len(lcText)
      lcLines[lnOffset]=lcLines[lnOffset]+;
      Substr(lcText,lnPosition,1)
      lnPosition = lnPosition + cnLines
   Enddo
   strtofile(chr(asc("a")+lnOffset-1)+lcLines[lnOffset]+;
   chr(13)+chr(10),ccDestinationfile,.t.)
endfor lnOffset

results in:
ahlwl
beood
cl,r!

Bye, Olaf.
 
Olaf, that is what I love in this forum:
Baltman had a good basic idea and you added further requirements...well done!

I only had to change your prog a litte bit, as I saw that in the encryption file the contents would be more readable (but not to much of course) when the text is written in upper letters and when commas are eliminated.

Now when my wife will see a sheet of paper in my wallet
where I have noted a girl friend it is very difficult for her to read *ggg

Code:
#define cnLines 3
#define ccDestinationfile "c:\temp\encrypted.txt"
lcText = "Julia Roberts, Schillerstrasse 15, 1000 Berlin, Tel 0574-658569 " && lcText = filetostr(getfile())
lcText = chrtran(lcText," ","") && maybe remove other chars - here blanks
lcText = chrtran(lcText,",","")  && removing comma
lcText = upper(lcText)

local array lcLines[cnLines]
strtofile("",ccDestinationfile,.f.)
For lnOffset = 1 to cnLines
   lcLines[lnOffset]=""
   lnPosition = lnOffset
   Do While lnPosition <= Len(lcText)
      lcLines[lnOffset]=lcLines[lnOffset]+;
      Substr(lcText,lnPosition,1)
      lnPosition = lnPosition + cnLines
   Enddo
   strtofile(chr(asc("A")+lnOffset-1)+lcLines[lnOffset]+;
   chr(13)+chr(10),ccDestinationfile,.t.)
endfor lnOffset

*to have a look on the result:
MODIFY COMMAND c:\temp\encrypted.txt
--------------------------
Result:
AJIORSIETS10BLT0456
BUABTCLRRS50EIE5-89
CLRESHLSAE10RNL765
---------------------------

Great!

AAGAOO
BBSRRU
CITFY!



Greetings
Klaus

Peace worldwide - it starts here...
 
Ha ha ha - gotta give baltman and Olaf a star just for being drawn into this.

Oh for those halcyon days when there was nowt better else to do than indulge!!

One small point, you need to use a fixed pitch font cos after about 5 columns it becomes almost unreadable.

Bob Palmer
The most common solution is H2O!
 
Hi Bob,

One small point, you need to use a fixed pitch font cos after about 5 columns it becomes almost unreadable.

..wich makes it even better "encrypted" :-).

Code:
lcText = chrtran(lcText," ","") && maybe remove other chars - here blanks
lcText = chrtran(lcText,",","")  && removing comma
lcText = upper(lcText)
can of couse be combined:
Code:
lcText = UPPER(chrtran(lcText," ,",""))

ChrTran works character wise, not like StrTran... Another improvement: An array is not needed, because each line is written to a file via strtofile(), so LOCAL lcLine and working with lcLine instead of lcLines[lnOffset] would be sufficient...

Bye, Olaf.
 
For me this exercise is very instructive learning more about string-handling with VFP - and as far as I know, one can learn and remember best by using a simple and funny problem.

Am I right?

Thx
Klaus

Peace worldwide - it starts here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top