Home   Archive   Permalink



encloak/decloak question

I am playing with encloak and decloak using REBOL/View 2.7.8.3.1 1-Jan-2011
    
this seems to be a weird behaviour.
    
>> m: encloak "1234567890" "abcd"
== {^P^_^\p}
>> n: decloak m "abcd"
== "1234567890"
>> n: decloak m "abcd"
== " <7^QT"
>> n: decloak m "abcd"
== "^D!=6^!]"
>>
    
trying to understand why is decloak returning a different value every time it is run. I was expecting it to give me the same result every time. i.e "1234567890" but it is not.


posted by:   nubie       14-Apr-2020/20:35:55-7:00



"HELP decloak" will show you that the first argument is modified, that is to say, decloak operates in-place. In fact after each of your n: operations n and m will be the same.

posted by:   Mark       14-Apr-2020/22:52:53-7:00



Just to expand om Mark's explanation. The simple fix is to throw in a COPY:
    
>> m: encloak "1234567890" "abcd"
== {^P^_^\p}
>> n: decloak copy m "abcd"
== "1234567890"
>> n: decloak copy m "abcd"
== "1234567890"
>> n: decloak copy m "abcd"
== "1234567890"

posted by:   Sunanda       15-Apr-2020/1:51:46-7:00



thanks Mark and Sunanda for your explanations :)

posted by:   nubie       15-Apr-2020/8:20:03-7:00



Name:


Message:


Type the reverse of this captcha text: "e s o l c s"



Home