Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

charCodeAt()?

Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
02-07-2008 03:17
The book I'm currently reading raised my interest in cryptography... So I googled for some algorhythms and found quite a few. Despite having read in the forums that good encryption is kinda too much for LSL, I'd like to try to convert some of the algorhythms into LSL.
Since most of the examples I found are in Javascript, it shouldn't be that much of a problem (don't even think about telling me now that this will most likely go beyond the capabilities of LSL *s*)...

The problem I have now, is, that a lot of these Javascripts use string-operations which aren't available in LSL. One of them is charCodeAt().
I thought about making a list with the UTF-8 codes and then search this list to determine the code of a particular character. But this seems not to be a good attempt since such a list would take up a lot of memory...

Does anybody here have a better idea to achieve the functionality of charCodeAt()?

(the page I found some quite interesting code-snippets can be found here: http://www.nordwest.net/hgm/krypto/algo.htm - page is in german, though...)
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
02-07-2008 03:37
I use UnicodeIntegerToUTF8 and UTF8ToUnicodeInteger found here:
_____________________
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
02-07-2008 04:07
That looks quite promising! :)

Thanks Day...
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-07-2008 09:13
Another possibility is to use llStringToBase64() before encrypting, and llBase64ToString() after decrypting. Then you only have to deal with an alphabet of 64 symbols.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-07-2008 14:25
I haven't updated the functions at http://lslwiki.net/lslwiki/wakka.php?wakka=Unicode recently. The most up to date functions can be found here:
https://wiki.secondlife.com/wiki/UTF-8

If you are interested in doing cryptography I recommend you take a look at my Base64 functions, I have written functions that allow for the manipulation of bytes and dwords in base64 strings. Rarely do you want to manipulate a single byte, usually you want to fiddle with a dword or qword (which my functions also do). For speed reasons I recommend you use the Global Buffer version of the functions.

https://wiki.secondlife.com/wiki/Combined_Library#Base64_.26_Hex_Encoding
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
02-07-2008 14:45
Thanks, Strife! I had a feeling you wrote those but the info wasn't there :S
_____________________
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
02-07-2008 16:36
Thanks Strife! (and everybody else who contributed)

I'll surely have a look at your functions... I'm pretty new to this so I hope I'll get the whole concept... :)
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
02-08-2008 02:00
http://wiki.secondlife.com/wiki/XTEA_Strong_Encryption_Implementation

very slow under the LSL VM but quite usable on the Mono beta sims.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
02-08-2008 04:20
Thanks Squirrel!

But: Did you just hear my head explode? :)

This kinda looks like rocket-science to me... I think I need some very quiet nights with lots of caffeine to understand what's going on there...
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-08-2008 09:39
Hell yeah. And my 31 bit modPow implementation also works in 0.2 seconds (5 seconds compiled to the normal VM; I think it used to take 45 seconds).

/54/df/140261/1.html
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-08-2008 11:15
You may be interested to look at the hashing functions I ported to LSL...
https://wiki.secondlife.com/wiki/MD4
https://wiki.secondlife.com/wiki/MD5
https://wiki.secondlife.com/wiki/SHA1
https://wiki.secondlife.com/wiki/SHA2 (224 & 256)

They aren't part of the combined library but a yet to be released hashing library.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey