Hello Alexey, If I understand well, you suggest that instead of trying to write a file containing bytes which might not exist in the current encoding, that I actually write a sequence of translated hexa looking like this :
F6A310... This solves the issue. Regards, Antoine -------- Original-Nachricht -------- Datum: Tue, 20 Jun 2006 09:39:23 -0700 Von: "Alexey N. Solofnenko" <[EMAIL PROTECTED]> An: Ant Users List <[email protected]> Betreff: Re: binary data and filterchain framework [was encrypting/decrypting] > That is why I put a note to use hexadecimal conversion for encrypted > strings. > > public static String asHex(byte buf[]) { > if (buf==null) > return null; > StringBuffer strbuf=new StringBuffer(buf.length*2); > for (int i=0, l=buf.length; i<l; i++) { > int b=buf[i]&0xFF; > if (b<0x10) > strbuf.append('0'); > strbuf.append(Long.toString(b, 16)); > } > return strbuf.toString(); > } > > public static byte[] fromHex(String str) { > if (str==null) > return null; > final int strLen=str.length(); > byte[] buf=new byte[strLen/2]; > for (int i=0, j=0; i<strLen; i+=2, j++) { > buf[j]= (byte)Integer.parseInt(str.substring(i, i+2), 16); > } > return buf; > } > > > - Alexey. > > Antoine Levy-Lambert wrote: > > Hey, > > > > I found something useful. > > > > The problem in the round trip binary data ===> string ===> binary data > > is that in standard western character sets, there are a lot of slots > which are marked "undefined". I had for instance a problem with 0x81 (decimal > 129) which was transformed into 0x3f (question mark). > > > > I found out that the Arabic Character Set Cp1256 has all slots used, so > can be used as a vehicle to do round trips with binary data using the > filterchain framework. > > > > Regards, > > > > Antoine > > > > [1] http://www.microsoft.com/typography/unicode/1250.htm this char set > has empty slots > > [2] http://www.microsoft.com/typography/unicode/1256.htm this char set > has no empty slots. > > > > -------- Original-Nachricht -------- > > Datum: Tue, 20 Jun 2006 09:13:49 -0400 > > Von: Antoine Levy-Lambert <[EMAIL PROTECTED]> > > An: Ant Users List <[email protected]> > > Betreff: Re: Ant tasks to encrypt or decrypt passwords from property > files > > > > > >> Hello Alexey, > >> > >> I have written something based on your code. > >> Actually, I wrote an ant task to create the key first. > >> I wanted to create filters (pluggable into filterchains) to encrypt and > >> decrypt, but I do not get that to work. > >> I might do an ant task to encrypt and a sort of loadproperties clone > >> which would take an encrypted file. > >> When I use filterchains and loadproperties, the decrypting does not > >> work, some of the bytes read by loadproperties (or the filterchain > >> framework) are not the same as the original. > >> Unfortunately, I am not litterate enough with streams, bytes, binary > >> operators and the like to know how to fix this. A shame, the solution > >> with filters would be elegant. > >> > >> Regards, > >> > >> Antoine > >> > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
