I think I copied that from addon , (8#2) #: a. i. 'a' 0 1 1 0 0 0 0 1 _6 [\ , (8#2) #: a. i. 'a' 0 1 1 0 0 0 0 1 0 0 0 0
the _6 [\ part converts a bit stream into chunks of 6, which #. will convert to a number from 0 to 63 ----- Original Message ----- From: Jon Hough <[email protected]> To: "[email protected]" <[email protected]> Cc: Sent: Tuesday, August 5, 2014 11:24:55 AM Subject: [Jprogramming] Base64 encoding I know there is an addon for doing base64 encoding ( http://www.jsoftware.com/jwiki/Addons/convert/misc#base64 ) , but I also stumbled across Pascal Jasmin's wiki entry on RSA, which included a function for base64 encoding data. http://www.jsoftware.com/jwiki/PascalJasmin/RSA%20native%20and%20openssl%20control?highlight=%28base64%29 The function istobase64=: 3 : 0 res=. BASE64 {~ #. _6 [\ , (8#2) #: a. i. y res, (0 2 1 i. 3 | # y) # '=' ) I understand this function somewhat, but cannot figure out why _6[\ is necessary. (clearly it works so this must be needed). My understanding is: 1. read y and convert to ASCII int value 2. write in binary (aside - how does that handle chars larger than one byte?, i.e. UTF) 3. , (ravel) concatenate into one array 4. Do the mysterious _6[\ 5. {~ #. encodes the result to the BASE64 alphabet. The biggest mystery to me is step 4. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
