Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 12:57 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Encryption
PostPosted: November 12th, 2005, 5:28 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

I'm trying to set encryption when I write to a disk txt file and read from it. The writing is easy, since it's done by the standard Opus write to disk file action, allowing for an easy check mark to set encryption and then entering a key. I can't get the the reading of the encrypted data to work.

For example, if I use an encrypt key of abc, I script it as
ReadField (true,"abc"), substituting it for ReadField(false), the prior unencrypted script. This doesn't work. I've tried substituting for all and then different ones, experimenting to see which, if not all, need substitution. Again, no success.

Here's the read/reset script for one object with no encryption set:

textobj = OpenFile("C:\\pos\\pos.txt");

ref = textobj.ReadField(false);
Debug.trace("ref = "+ref+"\n")

for (loop = 0; loop < ref; loop++)
{

x = textobj.ReadField(false);
y = textobj.ReadField(false);
Debug.trace("x = "+x+"\n")
Debug.trace("y = "+y+"\n")

myClone[loop] = frame.CloneObject(x,y,true);

var child = myClone[loop].GetFirstChild();
while (child)
{
var state = textobj.ReadField(false);
child.m_state = String.integer(state);

if (child.m_state == 0)
child.SetTransparency(100);
else
child.SetTransparency(0);

child = myClone[loop].GetNextChild(child);
}
}

The write to disk file is using the variable "save." As mentioned, this can be set for encryption. the script for "save" is:


save = ref + ",";

for (loop=0;loop<ref;loop++)
{
var pos = myClone[loop].GetPosition();

var objdata = pos.x + "," + pos.y;

var child = myClone[loop].GetFirstChild();
while (child)
{
objdata += "," + child.m_state;

child = myClone[loop].GetNextChild(child);
}

save += objdata;

if (loop < (ref - 1))
{
save += ",";
}
}

I would appreciate any help suggesting how to set this encryption using for example an "abc" key. I'm not sure which of the ReadField items need to be changed, and which should remian the same. I would also appreciate any other work-a-round to solve this, as well.

Kind Regards,
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: November 12th, 2005, 9:01 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
I hope you aren't working like me -- 7 days a week -- not enough hours in the week at present :-)

You should be using something like this to WRITE the file:

var textObj = OpenFile("c:\\myText.txt")
textObj.WriteField("Hello World",true,"abc")

And something like this to READ the file:

var textObj = OpenFile("c:\\myText.txt")
decryptedText=textObj.ReadField(true,"abc")

cheers
Paul -- see attached example pub.


Top
 Profile  
 
 Post subject:
PostPosted: November 12th, 2005, 11:15 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Thanks Paul for your reply and example.

Yes, 7 days a week, sometimes 8. :(

I would need to add a script to replace the standard Opus action "write to disk file."

But, since the only variable used for the original write to disk file action is "save," I'm not sure what (string?) to write into the script version.

Please take a look at the "save" sample script in my first posting above. What ("Hello World" item (s) would I use, based on that script, in my new save script? That's where I'm stuck. I've tried different ones, all unsuccessful.

Thanks for your help.

Stephen

By the way, isn't Spring where you are? Should be enjoying some of that beautiful outdoors. :)


Top
 Profile  
 
 Post subject:
PostPosted: November 13th, 2005, 12:57 am 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
Something like::

textObj.WriteField(save,true,"abc")

if save is your variable - - don't put save in quotes, otherwise Opus will think you want to send the string "save" and not it's contents.

The sun is shining, it's a beautiful day.
Pity I have to sit in the semi gloom that monitors (and my eyes) require.
Oh, stuff it -- I'm going for a walk.
Paul


Top
 Profile  
 
 Post subject:
PostPosted: November 13th, 2005, 1:21 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Paul

It's good to get some fresh air. Clears the cobwebs out.

Thanks for your reply. I tried adapting the script as suggested, and at least it decrypted. It won't, upon reset, however, display the object. The problem, based on using my debug.trace for decrypt/encrypt and for the variable <ref> (see script in earlier posting, above), follows:

decryptedText is: 1,390.5,217.5,1,1,1,0
encryptedText is:
ref =
refa = 0
refb = 0

My save and/or reset scripts for this object show no value for ref. Can't get it to display.

Any ideas?

Kind Regards,
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: November 13th, 2005, 2:37 am 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
File operations can be tricky -- read the help file and understand how ReadField, ReadLine, WriteField, WriteLine(), OpenFile, GotoNextLine(), EndOfFile() work and especially check what the default parameter settings are if you don't supply one.

Help file ref regards ReadField -- "This function will read a comma-separated file that has been opened with an OpenFile function. EACH TIME the function is called, the NEXT FIELD (i.e. text separated by commas) will be displayed."

Paul


Top
 Profile  
 
 Post subject:
PostPosted: November 13th, 2005, 5:16 am 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi Paul

Thanks, again.

I've read and re-read every applicable help file, tried every possible permutation of save, false, true, "abc" or true, false, "abc" and so forth, getting a variety of debug trace results ranging from ref = QN, to ref=0 to ref= (a blank here). While some of the combo's seem promising, showing a string of appropriate data (for other than ref,) no combo makes the object appear or resets it.

So, I've run out of road on this one. I can't think of any other combo's. May need to settle for some other work-a-round to secure the data.

All ideas will be welcome.

Kind Regards,
Stephen


Top
 Profile  
 
 Post subject:
PostPosted: November 13th, 2005, 4:45 pm 
Offline
Godlike
Godlike

Joined: November 11th, 2004, 1:18 pm
Posts: 1213
Location: New York
Opus: Opus Pro 9.75
OS: Windows 10 Pro 64 bit
System: Core i7, 16G RAM, Nvidia 640GT (desktop), plus Windows 10 and Android tablets
Hi

The scripting required to add encryption is beyond my capability. I've tried over and over, but can't get it right.

One possible work-a-round:

Is there any way to use standard Opus actions, like write to disk txt file (which allows encryption) and read from disk txt file (which can decrypt) instead of scripting?

The first script is already arranged using a standard Opus action: it is followed by a write to disk txt file action using the variable save to store to:

first script

save = ref + ",";

for (loop=0;loop<ref;loop++)
{
var pos = myClone[loop].GetPosition();

var objdata = pos.x + "," + pos.y;

var child = myClone[loop].GetFirstChild();
while (child)
{
objdata += "," + child.m_state;

child = myClone[loop].GetNextChild(child);
}

save += objdata;

if (loop < (ref - 1))
{
save += ",";
}
}

already followed by a write to disk txt file using the variable <save> to store the data, and allowing overwrite. (I could easily check encrypt and add a key here.)

It's the second script (used to read and reset data written by the first script that I can't figure out: (if I were to add encryption to the write to disk txt file action) how to de-encrypt and then re-display that data. If a read from disk txt file action, possibly coupled with read first line, read next line (or field), etc can be used, this could solve the issue nicely. :)

However, to do so would require re-writing the second script, probably eliminating the opening and read actions in it (allowing the read from disk txt file actions to substitute). I'm not sure how to re-write this script to keep necessary actions and eliminate those that would conflict with the read from disk txt file ones.

Here's the second script:

textobj = OpenFile("C:\\pos\\pos.txt");

ref = textobj.ReadField(false);
Debug.trace("ref = "+ref+"\n")

for (loop = 0; loop < ref; loop++)
{
x = textobj.ReadField(false);
y = textobj.ReadField(false);
Debug.trace("x = "+x+"\n")
Debug.trace("y = "+y+"\n")

myClone[loop] = frame.CloneObject(x,y,true);

var child = myClone[loop].GetFirstChild();
while (child)
{
var state = textobj.ReadField(false);
child.m_state = String.integer(state);

if (child.m_state == 0)
child.SetTransparency(100);
else
child.SetTransparency(0);

child = myClone[loop].GetNextChild child);
}
}

I would appreciate any help with this to get "un-stuck."

Kind Regards,
Stephen
swartel@nycap.rr.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group