Decoding (was: Re: [Jprogramming] ASCII bytes to string)

Roger Hui rhui000 at shaw.ca
Tue Sep 25 12:06:35 HKT 2007


Suppose

c=: ?256
d=: 16+?16
e=: a.{~ c (d b.) i.256
NB. e is used as:   map=: e {~ a. i. ]

Can you recover c and d given e?  c and d are not
necessarily unique so it suffices to compute c1 and d1
such that   e -: a.{~ c1 (d1 b.) i.256 .



----- Original Message -----
From: Roger Hui <rhui000 at shaw.ca>
Date: Monday, September 24, 2007 18:17
Subject: Re: [Jprogramming] ASCII bytes to string
To: Programming forum <programming at jsoftware.com>

> I'd forgotten that in J6.02, whose beta will be available soon, 
> the phrase p {~ q i. ]   where p and q are strings, is 
> supported 
> by special code.  Exploiting this phrase:
> 
> map=: (a.{~128 (23 b.) i.256) {~ a. i. ]
> 
> scramble2=: 3 : 0
>  (map read <y) write <y,'.scrambled'
> )
> 
>    ts 'scramble2 ''\junk\foo'''
> 0.0393609 4.1975e6
>    ts 'scramble2 ''\junk\foo1'''
> 0.0396972 4.19763e6


More information about the Programming mailing list