how do I encrypt a field?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
how do I encrypt a field?
Hello Forum,
I'm an amateur programmer who uses Livecode for educational/research purposes. I have a script question that I hope someone out there can help me with. I know that in pop-up windows you can tell Livecode to encrypt the information that the user sees -- for example:
ask password clear "What is your ID #?"
Does anyone know how to have Livecode encrypt the content entered into a field?
I'm an amateur programmer who uses Livecode for educational/research purposes. I have a script question that I hope someone out there can help me with. I know that in pop-up windows you can tell Livecode to encrypt the information that the user sees -- for example:
ask password clear "What is your ID #?"
Does anyone know how to have Livecode encrypt the content entered into a field?
-
- VIP Livecode Opensource Backer
- Posts: 10058
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: how do I encrypt a field?
I don't know the specific encryption method the engine uses for "ask password", but if you need to encrypt data you have at least two options:
For really-stupid-but-somewhat-useful-for-basic-tasks encryption, the pack and unpack functions here provide very rudimentary encryption that may be suitable if your security concerns are minimal:
http://livecodejournal.com/tutorials/ha ... s-005.html
Pack and unpack compress data before encryption and then pass it through base64Encode/decode, making them convenient for network transfer.
For industrial-strength encryption see the Dictionary entries for Rev's encrypt and decrypt commands, which offer options for Blowfish and other very powerful encryption methods. See also the cipherNames function which returns a list of available encryption methods.
If network transfer is desired you can easily pass the values altered by encrypt and decrypt through bas64encode/decode by call them in a simple accessor function, so while pack and unpack are small and convenient if you need truly strong encryption you may want to consider encrypt and decrypt.
For really-stupid-but-somewhat-useful-for-basic-tasks encryption, the pack and unpack functions here provide very rudimentary encryption that may be suitable if your security concerns are minimal:
http://livecodejournal.com/tutorials/ha ... s-005.html
Pack and unpack compress data before encryption and then pass it through base64Encode/decode, making them convenient for network transfer.
For industrial-strength encryption see the Dictionary entries for Rev's encrypt and decrypt commands, which offer options for Blowfish and other very powerful encryption methods. See also the cipherNames function which returns a list of available encryption methods.
If network transfer is desired you can easily pass the values altered by encrypt and decrypt through bas64encode/decode by call them in a simple accessor function, so while pack and unpack are small and convenient if you need truly strong encryption you may want to consider encrypt and decrypt.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: how do I encrypt a field?
Do you simply want to hide the entered data? Sort of like the bullets that appear in a field so that a casual onlooker cannot read your password as you type? There are several cute ways to effect this.
Or is Richard's reply about full blown file encryption more pertinent?
Write back if you need to.
Craig Newman
Or is Richard's reply about full blown file encryption more pertinent?
Write back if you need to.
Craig Newman
Re: how do I encrypt a field?
Yes, that's right, I just need to hide the data that our research participants type into the field with bullets or asterisks (long story short, we'll be asking people to type in the spelling of words but we don't want them to be able to see what they've typed, to prevent them from deciding if a spelling "looks right"). Thanks for any advice you have!
Re: how do I encrypt a field?
Hi.
This should get you started. Put these three handlers into your field script:
Not severely tested, but seems to work OK. I am using a custom property of the field to hold your actual data, and just filling in the field itself with bullets. If you read the scripts you should be able to see how this very simple thing works, and should be able to modify it so that you can display, or send along, the actual data if you need to.
Craig Newman
This should get you started. Put these three handlers into your field script:
Code: Select all
on keydown var
set the currentData of me to the currentData of me & var
put "•" after me
end keydown
on deleteKey
set the currentData of me to char 1 to -2 of the currentData of me
delete the last char of me
end deleteKey
on backspaceKey
set the currentData of me to char 1 to -2 of the currentData of me
delete the last char of me
end backspaceKey
Craig Newman
Re: how do I encrypt a field?
This is incredibly helpful, thank you so much for your prompt replies and advice!!
Cheers,
Katherine
Cheers,
Katherine
Re: how do I encrypt a field?
Thank you Craig...dunbarx wrote:Hi.
This should get you started. Put these three handlers into your field script:Not severely tested, but seems to work OK. I am using a custom property of the field to hold your actual data, and just filling in the field itself with bullets. If you read the scripts you should be able to see how this very simple thing works, and should be able to modify it so that you can display, or send along, the actual data if you need to.Code: Select all
on keydown var set the currentData of me to the currentData of me & var put "•" after me end keydown on deleteKey set the currentData of me to char 1 to -2 of the currentData of me delete the last char of me end deleteKey on backspaceKey set the currentData of me to char 1 to -2 of the currentData of me delete the last char of me end backspaceKey
Craig Newman
quick question, if I wanted to pull the information from the currentData custom property, how would I interact with it from another object?
would I need to make currentData a global variable?
- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
Re: how do I encrypt a field?
Hi Rich,
you can address a CP directly:
...
put the CurrentData of btn "the one with the CP" into whatever
## or whatever object holds this CP
## or even from other cards and/or stacks:
## put the CurrentData of btn "the one with the CP" of cd "XY" of stack "Z" into whatever
...
Best
Klaus
you can address a CP directly:
...
put the CurrentData of btn "the one with the CP" into whatever
## or whatever object holds this CP
## or even from other cards and/or stacks:
## put the CurrentData of btn "the one with the CP" of cd "XY" of stack "Z" into whatever
...
Best
Klaus
Re: how do I encrypt a field?
"CurrentData" is the custom property that was created in the various handlers in the field script. It was created on the fly by setting it to the value of the key pressed. It was updated in a similar fashion. Custom properties may be manipulated in all the usual ways that any other property is. One may set them and get them.
Since the actual data is "in" the custom property of the field, Simply:
get the currentData of fld "yourField"
Properties are not containers, so you cannot "put" something into a property.
Since the actual data is "in" the custom property of the field, Simply:
get the currentData of fld "yourField"
Properties are not containers, so you cannot "put" something into a property.
Re: how do I encrypt a field?
Thank you Klaus and dunbarx....
I tried the following in a button:
but comes back with currentData... not the content of current data.
EDIT:
actually.. I get an error after:
I tried the following in a button:
Code: Select all
on mouseUp
answer info currentData of Field 1
end mouseUp
EDIT:
actually.. I get an error after:
Code: Select all
button "Button": execution error at line 2 (Handler: can't find handler) near "of", char 16
- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
Re: how do I encrypt a field?
Hi Rich,
clean your glasses, please!
As we already unmistakably wrote in our postings:
...
answer THE currentData of fld 1
...
Best
Klaus
clean your glasses, please!

As we already unmistakably wrote in our postings:
...
answer THE currentData of fld 1
...

Best
Klaus
Re: how do I encrypt a field?
hehe.. consider glasses cleaned 
it was odd though, the moment I closed out of LiveCode and relaunched.. it started to work again..
this works:
thanks again
// Still getting used to the syntax 

it was odd though, the moment I closed out of LiveCode and relaunched.. it started to work again..
this works:
Code: Select all
put the currentData of Field "passwordField" into tData
answer info the currentData of Field "passwordField"


- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
Re: how do I encrypt a field?
Klaus.
There is another parameter that can be associated with the answer command. It is the icontype, and "information" (and, I guess, "info) is allowed. The "the" is optional when calling a property. Both these work:
answer the testProperty of yourObject
answer testProperty of yourObject
HC also allowed this flexibility.
There is another parameter that can be associated with the answer command. It is the icontype, and "information" (and, I guess, "info) is allowed. The "the" is optional when calling a property. Both these work:
answer the testProperty of yourObject
answer testProperty of yourObject
HC also allowed this flexibility.
Re: how do I encrypt a field?
Rich.
I would always be careful with syntax. Errant words that seem to read better usually will break something, however forgiving this language is.
So "info" as a valid synonym for "information" (as per the examples in the "answer" command from the dictionary), was just lucky. It threw Klaus and I. Ahem.
I really recommend using "the" when calling properties. Everyone expects it; you should as well.
I am thrown much more often than Klaus is, I should mention.
I would always be careful with syntax. Errant words that seem to read better usually will break something, however forgiving this language is.
So "info" as a valid synonym for "information" (as per the examples in the "answer" command from the dictionary), was just lucky. It threw Klaus and I. Ahem.
I really recommend using "the" when calling properties. Everyone expects it; you should as well.
I am thrown much more often than Klaus is, I should mention.
Re: how do I encrypt a field?
Hi Rich,
yep, I strongly recommend to stick to the official syntax!
The engine might not be so forgiving in future releases!
And please lookup every unknown and/or new term in the Dictionary
to check the official syntax and get more info about it.
Best
Klaus
yep, I strongly recommend to stick to the official syntax!
The engine might not be so forgiving in future releases!
And please lookup every unknown and/or new term in the Dictionary
to check the official syntax and get more info about it.
Best
Klaus