I have been playing with encryption using RSA keys. I have generated a key-pair; however, I cannot seem to figure out how to put either of the keys into a variable for using to encrypt and decrypt.
both of the keys are rather long strings...do I need to encode them somehow. Wrapping in quotes does not seem to work.
Any clues?
Put RSA key into variable
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
-
- VIP Livecode Opensource Backer
- Posts: 92
- Joined: Mon Jul 06, 2009 4:53 am
Re: Put RSA key into variable
The LiveCode dictionary says that the keys should be in pem format and shows how to create then using openSSL.
I successfully tried this code:
put the Version & return
put "See if it works" into tSecret
put URL "binfile:private_key.pem" into tPrivateKey
put URL "binfile:public_key.pem" into tPublicKey
encrypt tSecret using rsa with private key tPrivateKey
put it & return
decrypt it using rsa with public key tPublicKey
put it & return
[/code]
I got these results:
Hope this helps.
I successfully tried this code:
Code: Select all
#!livecode
if the environment is "server" and the platform is "MacOS" then
set the outputLineEndings to "lf"
set the outputTextEncoding to "utf8"
end if[code]
put the Version & return
put "See if it works" into tSecret
put URL "binfile:private_key.pem" into tPrivateKey
put URL "binfile:public_key.pem" into tPublicKey
encrypt tSecret using rsa with private key tPrivateKey
put it & return
decrypt it using rsa with public key tPublicKey
put it & return
[/code]
I got these results:
Code: Select all
mbp:LiveCodeServer peter$ ./rsa_test.lc
8.0.0-dp-1
wÃ˚_E
çI;íµdáäÀ»õˆÎ¢Ëª·Jå.10˘p Ã1îèúeX>¶){N3˚4`
See if it works
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: Put RSA key into variable
Thanks for replying.
Since I was getting no responses here, I started another post on a similar topic:
http://forums.livecode.com/viewtopic.php?f=11&t=23812
and had my question answered.
Since I was getting no responses here, I started another post on a similar topic:
http://forums.livecode.com/viewtopic.php?f=11&t=23812
and had my question answered.