Prev: Hello, guys! I just confirmed the complete and utterdetestation of an entire arm of cryptography!? Little applause, comeon.... I work hard.. :)
Next: A A
From: jbriggs444 on 20 May 2010 12:08 On May 20, 10:44 am, "astral" <ast...(a)news.eternal-september.org> wrote: > "Phoenix" <ribeiroa...(a)gmail.com> wrote in message > > news:a01b81bf-54b2-417f-90c5-abb5731f685d(a)e28g2000vbd.googlegroups.com... > > > > > On 20 Maio, 14:04, "astral" <ast...(a)news.eternal-september.org> wrote: > > >> what mean your code? Is it for unix system? If for Windows, how to use > >> it, > >> where is delimiter? > > > --------------------------------------------------------------------- > > Follow the linkhttp://www.fourmilab.ch/xd/ > > > Download xd.zip. > > > The release archive contains source code, a Makefile for building the > > program, and documentation in manual page and HTML form. A ready-to- > > run WIN32 executable, xd.exe is included, along with the workspace and > > project definition files used to build it with Microsoft Visual C 5.0. > > --------- > I tried XD program but, decimal output look a bit inaccurate, > 77,90,144,0,3,0,0,0,4,0,0,0,255,255,0,0,184,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,240,0,0,0,14,31,186,14,.. > > dont see way to set custom delimiter, or use 3 digit representation for all > strings- Hide quoted text - > > - Show quoted text - Inserting a delimiter is a text processing problem. Don't suppose you've ever heard of notepad, or done a search and replace within notepad?
From: jbriggs444 on 20 May 2010 12:10 On May 20, 9:51 am, Mok-Kong Shen <mok-kong.s...(a)t-online.de> wrote: > astral wrote: > > > "jbriggs444" wrote: [...] > > $ dump /decimal sys$system:dump.exe /output=myfile.txt [...] > What jbriggs444 wrote is evidently for unix. What do you mean by > delimiter? Do you mean you need a special symbol of your choice after > each n decimal or hexadecimal digits? In that case I am afraid that you > have to spend a (tiny) little time to write a few lines of C code. > I tossed in some VMS in too, just to see if anyone would recognize it.
From: astral on 20 May 2010 13:05 "jbriggs444" <jbriggs444(a)gmail.com> wrote in message news:617191ed-81fc-468e-8e1f-10d8ee5c5914(a)g39g2000pri.googlegroups.com... On May 20, 10:44 am, "astral" <ast...(a)news.eternal-september.org> wrote: > "Phoenix" <ribeiroa...(a)gmail.com> wrote in message > > news:a01b81bf-54b2-417f-90c5-abb5731f685d(a)e28g2000vbd.googlegroups.com... > > > > > On 20 Maio, 14:04, "astral" <ast...(a)news.eternal-september.org> wrote: > > >> what mean your code? Is it for unix system? If for Windows, how to use > >> it, > >> where is delimiter? > > > --------------------------------------------------------------------- > > Follow the linkhttp://www.fourmilab.ch/xd/ > > > Download xd.zip. > > > The release archive contains source code, a Makefile for building the > > program, and documentation in manual page and HTML form. A ready-to- > > run WIN32 executable, xd.exe is included, along with the workspace and > > project definition files used to build it with Microsoft Visual C 5.0. > > --------- > I tried XD program but, decimal output look a bit inaccurate, > 77,90,144,0,3,0,0,0,4,0,0,0,255,255,0,0,184,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,�0,0,0,240,0,0,0,14,31,186,14,.. > > dont see way to set custom delimiter, or use 3 digit representation for > all > strings- Hide quoted text - > > - Show quoted text - Inserting a delimiter is a text processing problem. Don't suppose you've ever heard of notepad, or done a search and replace within notepad? ------------ Of course, I can do this with notepad. Sure I didn't expected to get too much from the console program.
From: rossum on 21 May 2010 10:22 On Thu, 20 May 2010 17:02:35 +0300, "astral" <astral(a)news.eternal-september.org> wrote: >..code for Real operating system. Windows have no such features, likely? >Delimiter: instead of decimal output like this 52,136,7,0,0,0,0, >set this: t(102),t(097),t(229),t(224),t(077),t(247),t(208),t(000) How is your Java? rossum // --- Begin Code --- public class Main { public static void main(String[] args) { java.util.Random rand = new java.util.Random(); // Generate some random data. byte[] bytes = new byte[15]; rand.nextBytes(bytes); // Convert the data. ByteToText btt = new ByteToText(); btt.setBase(ByteToText.Base.DECIMAL); btt.setPadding(ByteToText.Padding.THREE_DIGITS); btt.setInitialDelim("t("); btt.setMidDelim("),t("); btt.setFinalDelim(")"); String result = btt.convert(bytes); // Show the result. System.out.println(result); } // end main() } // end class Main /** byte to hex/decimal converter */ class ByteToText { /** enum for allowed paddings. */ public enum Padding { NO_PAD(1), TWO_DIGITS(2), THREE_DIGITS(3); private final int mPadSize; Padding(int p) { mPadSize = p; } public int getPadSize() { return mPadSize; } } // end enum Padding /** enum for allowed number bases. */ public enum Base { HEX('H'), // Upper case hex: AF LOWER_HEX('h'), // Lower case hex: af DECIMAL('d'); private final char mBase; Base(char b) { mBase = b; } public char getBase() { return mBase; } } // end enum Base // Default delimiters final static String DEF_INIT_DELIM = "{"; final static String DEF_MID_DELIM = ", "; final static String DEF_FINAL_DELIM = "}"; // Other defaults final static Padding DEF_PAD = Padding.NO_PAD; final static Base DEF_BASE = Base.DECIMAL; // Delimiters private String mInitialDelim = DEF_INIT_DELIM; private String mMidDelim = DEF_MID_DELIM; private String mFinalDelim = DEF_FINAL_DELIM; private Padding mPadding = DEF_PAD; private Base mBase = DEF_BASE; // Constructor public ByteToText() { } // Getters and setters public Padding getPadding() { return mPadding; } public void setPadding(Padding padding) { mPadding = padding; } public Base getBase() { return mBase; } public void setBase(Base base) { mBase = base; } public String getFinalDelim() { return mFinalDelim; } public void setFinalDelim(String finalDelim) { mFinalDelim = finalDelim; } public String getInitialDelim() { return mInitialDelim; } public void setInitialDelim(String initDelim) { mInitialDelim = initDelim; } public String getMidDelim() { return mMidDelim; } public void setMidDelim(String midDelim) { mMidDelim = midDelim; } // Method /** Converts a byte array to text using the current settings. */ public String convert(byte[] bytes) { String formatter = "%0" + mPadding.getPadSize() + mBase.getBase(); int multiplier = 1 + mPadding.getPadSize() + mMidDelim.length(); StringBuilder result = new StringBuilder(bytes.length * multiplier + 10); for (int i = 0; i < bytes.length; ++i) { if (i > 0) { result.append(mMidDelim); } // I hate Java's signed bytes! int current = (bytes[i] >= 0) ? bytes[i] : 256 + bytes[i]; result.append(String.format(formatter, current)); } return mInitialDelim + result.toString() + mFinalDelim; } } // end class ByteToHex // --- End Code --- /******************* Sample output: t(185),t(000),t(155),t(156),t(221),t(213),t(144),t(081),t(166),t(041), t(208),t(190),t(026),t(022),t(239) /*******************/
From: jbriggs444 on 21 May 2010 11:37
On May 21, 10:22 am, rossum <rossu...(a)coldmail.com> wrote: > On Thu, 20 May 2010 17:02:35 +0300, "astral" > > <ast...(a)news.eternal-september.org> wrote: > >..code for Real operating system. Windows have no such features, likely? > >Delimiter: instead of decimal output like this 52,136,7,0,0,0,0, > >set this: t(102),t(097),t(229),t(224),t(077),t(247),t(208),t(000) > > How is your Java? My Java is non-existent. My Perl isn't expert, but it gets the job done. To Astral: I wrote and tested this on Windows using a downloaded copy of Perl. #!/usr/bin/perl # # produce a formatted dump of the named input file # If no input file is given, standard input is assumed # if ( $#ARGV > 0 ) { print STDERR "Too many arguments\n"; } elsif ( $#ARGV == 0 ) { $filename = $ARGV[0]; open ( STDIN, '<', $filename ) or die "Can't open $filename \n"; }; binmode(STDIN); $buffer = ""; while ( $len = read (STDIN, $buffer, 10 ) ) { $first = 1; foreach $byte ( split ( //, $buffer ) ) { if ( $first ) { $first = 0; } else { print ","; }; printf ( "t(%03d)", ord($byte) ); }; print "\n"; }; G:\perl\test>binary.pl binary.pl t(035),t(033),t(047),t(117),t(115),t(114),t(047),t(098),t(105),t(110) t(047),t(112),t(101),t(114),t(108),t(013),t(010),t(035),t(013),t(010) [...] t(110),t(116),t(032),t(034),t(092),t(110),t(034),t(059),t(013),t(010) t(125),t(059),t(013),t(010),t(009),t(013),t(010),t(009) (apparently I have a dangling tab on my last line). |