Hi Dirk, Did you look at libs/crypto/hmac.factor? I think we already have the equivalent of this code. It's more complicated because I tried to optimize md5-hmac to open streams less but I didn't benchmark to see if it's even much faster.
Pasting from the UI is sort of supported. The screen tends to shift right when you select text so it's awkward, but just select it and copy/paste as normal. A couple more tricks if that doesn't work: - right click the text and "unparse" it - if you have the text on the stack do "foo.txt" <file-writer> [ . ] with-stream I hope this helps. Doug On May 24, 2007, at 10:33 AM, Dirk Vleugels wrote: > Hi, > > im lurking on the list for quite a while, but this is my first try to > generate some factor code: > > =cut > > USING: crypto sequences math kernel base64 ; > IN: cram-md5 > > ! see http://en.wikipedia.org/wiki/HMAC > > : ipad ( key -- ipad ) [ HEX: 36 bitxor ] map ; > : opad ( key -- opad ) [ HEX: 5C bitxor ] map ; > > : padto64 ( str -- padded-str ) 64 0 pad-right ; > > : trim-key ( key -- padded-key ) dup length 64 > [ string>md5 ] [ > padto64 ] if ; > > ! MD5(K XOR opad, MD5(K XOR ipad, text)) > : hmac-md5 ( challenge key -- digest ) > trim-key 2dup ipad swap append string>md5 >> r nip opad r> append string>md5str ; > > ! calculate response string, challenge expected i clear text > : cram-md5 ( user challenge key -- reponse ) > hmac-md5 " " swap append append >base64 ; > > =cut > > The goal is to add cram-md5 authentication support to the smtp lib ( > which will be the hard part). It took to long to get this running (90 > mins), but was fun anyways ... > > Is the code above ok? > > Question: is there a way to copy&paste something from the > factor-listener (a string representation) to a terminal for example? > This is on macosx-x86 running 0.89. > > Cheers, > Dirk > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Factor-talk mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/factor-talk > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
