From owner-freebsd-questions@FreeBSD.ORG Sat Sep 22 07:52:24 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB6EA16A418 for ; Sat, 22 Sep 2007 07:52:24 +0000 (UTC) (envelope-from wundram@beenic.net) Received: from mail.beenic.net (mail.beenic.net [83.246.72.40]) by mx1.freebsd.org (Postfix) with ESMTP id 71CB313C457 for ; Sat, 22 Sep 2007 07:52:24 +0000 (UTC) (envelope-from wundram@beenic.net) Received: from phoenix (hnvr-4db2ee64.pool.einsundeins.de [77.178.238.100]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.beenic.net (Postfix) with ESMTP id E25CAA44529; Sat, 22 Sep 2007 09:48:18 +0200 (CEST) From: "Heiko Wundram (Beenic)" Organization: Beenic Networks GmbH To: freebsd-questions@freebsd.org Date: Sat, 22 Sep 2007 09:52:20 +0200 User-Agent: KMail/1.9.7 References: <38b9f0350709220019n227bf345v9006351554c73bdb@mail.gmail.com> In-Reply-To: <38b9f0350709220019n227bf345v9006351554c73bdb@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200709220952.21527.wundram@beenic.net> Cc: ronggui Subject: Re: How to convert ASCII to Hexadecimal format? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Sep 2007 07:52:24 -0000 Am Samstag 22 September 2007 09:19:02 schrieb ronggui: > for example: > ASCII: a test > HEX : 61 20 74 65 73 74 A small Python script to do the same (in case you need more control, adapt it as it suits you). --- #!/usr/bin/python from sys import argv for c in " ".join(argv[1:]).decode("ascii"): print hex(ord(c))[2:].upper(), --- [modelnine@phoenix ~]$ python test.py this is a test 74 68 69 73 20 69 73 20 61 20 74 65 73 74 [modelnine@phoenix ~]$ -- Heiko Wundram Product & Application Development