Encrypt/Decrypt using URL

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Encrypt/Decrypt using URL

Ari Denison
I'm looking for a solution to pass information through a URL from one page to another.

test1.lasso
<?LassoScript
        local(message='Hello World')

        local(eMessage=encrypt_blowfish(-seed='abcdefghijkl1234567890', #message))

        local(eMessageHex=#eMessage->encodeHex)
       
        '<a href="test2.lasso?i=' + #eMessageHex + '">Decrypt</a>'
?>

which gives me this…. test2.lasso?i=A127065D83B88ADE1686A1

test2.lasso
<?LassoScript
        handle_error;
                'ERROR: ' + error_currenterror
                abort;
        /handle_error;
       
        decrypt_blowfish(-seed='abcdefghijkl1234567890', action_param('i')->decodeHex)
?>

Results in… ERROR: Definition Not Found: string->decodehex()
       
I'm sure I'm missing something very basic here. Can someone help?
       


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

RE: Encrypt/Decrypt using URL

Rick Draper-2
Hi Ari,

This looks like Lasso 9 code - yes?

The following is taken from a method we use all the time - it should get you headed in the right direction.

local(encrypted) = (encode_base64url(encrypt_blowfish(#message, -seed = #key)))

local(decrypted) = (decrypt_blowfish(decode_base64(#encMessage), -seed = #key))

Very best regards,

Rick


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Encrypt/Decrypt using URL

Brad Lindsay-2
In reply to this post by Ari Denison

On Jan 25, 2013, at 6:51 PM, Ari Denison <[hidden email]> wrote:

> I'm looking for a solution to pass information through a URL from one page to another.
>
> test1.lasso
> <?LassoScript
> local(message='Hello World')
>
> local(eMessage=encrypt_blowfish(-seed='abcdefghijkl1234567890', #message))
>
> local(eMessageHex=#eMessage->encodeHex)
>
> '<a href="test2.lasso?i=' + #eMessageHex + '">Decrypt</a>'
> ?>
>
> which gives me this…. test2.lasso?i=A127065D83B88ADE1686A1
>
> test2.lasso
> <?LassoScript
> handle_error;
> 'ERROR: ' + error_currenterror
> abort;
> /handle_error;
>
> decrypt_blowfish(-seed='abcdefghijkl1234567890', action_param('i')->decodeHex)
> ?>
>
> Results in… ERROR: Definition Not Found: string->decodehex()
>
> I'm sure I'm missing something very basic here. Can someone help?

First, I just want to note that encrypt_blowfish returns an object of type bytes, not string, which you call the "encodeHex" member method.

So, you have two options:
   1) Cast action_param as a bytes object
        decrypt_blowfish(-seed='abcdefghijkl1234567890', bytes(action_param('i'))->decodeHex)

   2) You can use the [encode_hex] and [decode_hex] methods on strings as well as bytes:
        decrypt_blowfish(-seed='abcdefghijkl1234567890', decode_hex(action_param('i')))


HTH,
Brad
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Encrypt/Decrypt using URL

Ari Denison
In reply to this post by Rick Draper-2
Once I figured out that encode_base64url was something to be found on tagswap, this worked very well. Many thanks!

On Jan 25, 2013, at 6:04 PM, Rick Draper <[hidden email]> wrote:

> Hi Ari,
>
> This looks like Lasso 9 code - yes?
>
> The following is taken from a method we use all the time - it should get you headed in the right direction.
>
> local(encrypted) = (encode_base64url(encrypt_blowfish(#message, -seed = #key)))
>
> local(decrypted) = (decrypt_blowfish(decode_base64(#encMessage), -seed = #key))
>
> Very best regards,
>
> Rick
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Encrypt/Decrypt using URL

Jolle Carlestam-3
27 jan 2013 kl. 07:57 skrev Ari Denison <[hidden email]>:

> Once I figured out that encode_base64url was something to be found on tagswap, this worked very well. Many thanks!

FWIW, here's the Lasso 9 version:
<?LassoScript
/**!
encode_base64url
Lasso 8 version written by Jason Huck, published on Tagswap
Lasso 9 version by Jolle Carlestam 2011-03-14
**/
define encode_base64url(
        in
) => {
    return ((encode_base64(#in) -> removetrailing('=')&) -> replace('+', '-')&) -> replace('/', '_')&
}

/**!
decode_base64url
Lasso 8 version written by Jason Huck, published on Tagswap
Lasso 9 version by Jolle Carlestam 2011-03-14
**/
define decode_base64url(
        in::string
) => {

    local( 'out' = (#in -> replace('-', '+')&) -> replace('_', '/')& )
    if( (#out -> size % 4) ) => {
        #out += ('=' * (4-(#out -> size % 4)))
    }
    return decode_base64(#out)

}
?>

HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: Encrypt/Decrypt using URL

Brad Lindsay-2

On Jan 27, 2013, at 10:54 PM, Jolle Carlestam <[hidden email]> wrote:

> 27 jan 2013 kl. 07:57 skrev Ari Denison <[hidden email]>:
>
>> Once I figured out that encode_base64url was something to be found on tagswap, this worked very well. Many thanks!
>
> FWIW, here's the Lasso 9 version:
> <?LassoScript
> /**!
> encode_base64url
> Lasso 8 version written by Jason Huck, published on Tagswap
> Lasso 9 version by Jolle Carlestam 2011-03-14
> **/
> define encode_base64url(
> in
> ) => {
>    return ((encode_base64(#in) -> removetrailing('=')&) -> replace('+', '-')&) -> replace('/', '_')&
> }
>
> /**!
> decode_base64url
> Lasso 8 version written by Jason Huck, published on Tagswap
> Lasso 9 version by Jolle Carlestam 2011-03-14
> **/
> define decode_base64url(
> in::string
> ) => {
>
>    local( 'out' = (#in -> replace('-', '+')&) -> replace('_', '/')& )
>    if( (#out -> size % 4) ) => {
>        #out += ('=' * (4-(#out -> size % 4)))
>    }
>    return decode_base64(#out)
>
> }
> ?>

This is why I prefer encode_hex: it's already URL encoded.

Brad

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>