Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - kanen

#16
newLISP and the O.S. / (net-service) on Windows?
September 19, 2014, 10:34:58 AM
Is it possible to use (net-service) on Windows?



I've tried a few different ways to do this and none of them seem to work properly.



Anyone?
#17
newLISP in the real world / Re: Syllables
September 08, 2014, 02:52:53 PM
You guys are very helpful. With a little training and some newLisp magic, I figured it out and created a giant table from my results.



(set 'phonetics '(
  ("AABERG" 2)
  ("AACHEN" 2)
  ("AACHENER" 3)
  ("AAKER" 2)
  ("AALSETH" 2)
  ("AAMODT" 2)
  ("AANCOR" 2)
  ("AARDEMA" 3)
  ("AARDVARK" 2) ... )
#18
newLISP in the real world / Syllables
September 07, 2014, 12:59:44 PM
I'm doing something which requires me to understand how many syllables are in a word I've retrieved.



Anyone have any experience figuring this out in newLisp?
#19
I'm trying to figure out if any of the items in a bigger list are in a smaller list. I've tried a bunch of options, but none of them are fast enough.


(setf big-list '( ((5 0 0 0 3 14 0 1 0 0 1 0 0 0 0 0 0) 1006) ((8 97 108 45 106 105 110 97 110 3 110 101 116 0 0 1 0 1) 1001) ((8 97 49 45 106 105 110 97 110 3 110 101 116 0 0 1 0 1) 1001) ((6 97 114 100 100 114 97 4 104 111 115 116 2 115 107 0 0 1 0 1) 1001) ((3 119 119 119 5 106 111 45 117 102 3 110 101 116 0 0 1 0 1) 1001) ((3 119 119 119 12 106 111 102 112 109 117 121 116 114 118 99 102 3 99 111 109 0 0 1 0 1) 1001) ((71 69 84 32) 1001) ((46 46 47 46 46 47 46 46 47) 232) ((205 128 232 215 255 255 255) 232) ((7 10 0 0 0 75 0 208 0) 286) ((7 0 0 0 0 75 0 208 0) 286) ((0 0 0 0 3 97 112 105 7) 1010) ))
;
(setf small-list '(59 126 1 0 0 1 0 0 0 0 0 0 3 97 112 105 7 116 119 105 116 116 101 114 3 99 111 109 0 0 1 0 1) )


Is there a REALLY FAST way to see if an item in the big-list is contained within the small-list and return the value associated with the big-list content?  For example;


> (last big-list)
((0 0 0 0 3 97 112 105 7) 1010)


I can now do something like:


(intersect ((last big-list) 0) small-list)
; (0 3 97 112 105 7)


If the above was present in the small-list (which it is in this case), I'd want to return 1010, which is the "value" of that line in the big-list.



The only problem with this way of doing it is the "0" gets squashed into one value, so I don't get a "this is an exact match". Also, intersect seems to be slower than I'd like.



Thanks!
#20
Thanks!



I've never even used (set-ref) before, in all my years of newLisp. Everyday, as they say... you learn a thing.
#21
I have a list:


(set (global 'me) '(
  (80 (1010 ((84 114 117 115 116 80 105 112 101 73 115 65 119 101 115 111 109 101))) )
  (25 (1010 ((84 114 117 115 116 80 105 112 101 73 115 65 119 101 115 111 109 101))) )
  ))


I can get to it fairly easily;


(assoc 80 me)                     ; returns all "80" results
(assoc (list 80 1010) me)         ; returns all "80" + "1010" results
(last (assoc (list 80 1010) me))  ; returns the list for 80 + 1010


My question is, how do I insert a list into the results from (last (assoc (list 80 1010) me)) easily and quickly? I can get the results, insert into them, then re-insert the new list... but, I'd rather do this all-at-once.
#22
Quote from: "Lutz"We posted the last at the same second, see the difference of "b" and "c" in pack/unpack.


Right, but I'm still asking: What the best way to pack enc_str back into 00 format for (encrypt).

I'm using this function, which gets an enc_str like "001003024" but it doesn't work on non UTF-8 systems, sadly.
(join (map char (map (fn (x) (int x 0 10)) (explode enc_str 3))))
#23
So, the question is...

(setf enc_str "067020093000014001022091071092094008065017083090010089067030020084002084018094006091029018016000092085067042093051080017023064052051093080")
(setf enc_str (join (map char (map (fn (x) (int x 0 10)) (explode enc_str 3)))))

How do I turn this into something that works with (encrypt) non UTF-8 systems?

I can't seem to get (pack) to work the way I want.



Also, I can't compile newlisp on Android with UTF-8 support, because when I add UTF-8, I get hundreds of compile and link errors, starting with "newlisp.c:3524: undefined reference to `wchar_utf8"
#24
Figured it out -- I think.



(edit: spoke too soon...  a text_enc of "90600009" maps to (90 60) and the 9 gets removed. So I have to use the original, very long: (join (map (fn (x) (format "%03d" x)) (unpack (dup "c" (length text_enc)) text_enc)) )

I return the JavaScript happy version this way:
(setf rtn_blob (join (map (fn (x) (format "%03d" x)) (map char (explode text_enc)))))

And, transform the JavaScript version to newLisp this way:
(setf enc_str (join (map char (map (fn (x) (int x 0 10)) (explode enc_str 3)))))

Which I then pass to (encrypt enc_str my_pvt_password).
#25
Quote from: "cormullion"Perhaps Base64 encode/code it while its' travelling ?

Doesn't solve the problem that JavaScript only wants it as a string of integers.
#26
I am using the newLisp (encrypt) function to encrypt something and need to decrypt it somewhere else, in JavaScript. Then, I have to send back a response from JavaScript and decrypt it in newLisp.



My JavaScript is weak-sauce, but here's the gist (cobbled together from the Internets): https://gist.github.com/a110621fe731facb40ff">https://gist.github.com/a110621fe731facb40ff



The newLisp encrypt response looks like this:
> (setf text_enc (encrypt "My name is Earl." "foobar")
"+22O12003103O0617A7072903L"))


Whereas the JavaScript output looks like this:
> (encrypt("My name is Earl.", "foobar")
043022079012000031003079006017065055007029003076


I can make a few changes, like:
> (unpack (dup "c" (length str)) str)
(43 22 79 12 0 31 3 79 6 17 65 55 7 29 3 76)


But, I still end up with something that's not properly JavaScript-y.



If I force everything to be properly formatted for JavaScript, it all works out...
(join (map (fn (x) (format "%03d" x)) (unpack (dup "c" (length text_enc)) text_enc)) )
> "043022079012000031003079006017065055007029003076"


Until I try to go back to the format (encrypt) expects, then I'm at a loss. Because I can't just say...
> (join (map (fn (x) (pack (dup "c" 3) x)) (explode js_text 3)))
"Ѐ?0?0016 0@P`p???"


I've tried (pack "n" x) and several other options. Nothing seems to get me where I need to be.



Anyone?



P.S. Why doesn't newLisp have SHA256 or AES again? :(
#27
newLISP in the real world / Re: SHA2 Module
December 25, 2012, 06:01:23 PM
I'm basically thinking of porting this link http://www.movable-type.co.uk/scripts/sha256.html">http://www.movable-type.co.uk/scripts/sha256.html to newLisp.



Unfortunately, I'm waist-deep in Android right now...
#28
newLISP and the O.S. / Re: newLisp on Android (redux)
December 25, 2012, 05:59:58 PM
As of a few weeks ago, this is done. See the forums for details. :)
#29
newLISP in the real world / Re: SHA2 Module
December 25, 2012, 01:40:00 PM
I'm trying to do this in newLisp, so I don't ever have to rely on a an external library.


Quote from: "Lutz"You could do a smaller library using those two files:



http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-7/Source/sha2.c?txt">http://www.opensource.apple.com/source/ ... sha2.c?txt">http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-7/Source/sha2.c?txt

http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-7/Source/sha2Priv.h?txt">http://www.opensource.apple.com/source/ ... Priv.h?txt">http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-7/Source/sha2Priv.h?txt



gcc sha2.c -shared -o sha2.dylib



compiles without a problem on OSX to a sha2.dylib of about 29K
#30
newLISP in the real world / SHA2 Module
December 25, 2012, 11:54:16 AM
Has anyone written an SHA2 module or function that doesn't rely on libcrypto?



I have an MD5 hash function that works, but I'm worried about collisions.



Anyone?