- Convert String to Hexadecimal on Command Line
- Conversion hex string into ascii in bash command line
- bash ascii to hex
- Convert binary data to hexadecimal in a shell script
- Convert hex string to ASCII string in Windows batch file
- Is there any way to convert the hex code from string to hex colour which discord.py supports?
- Ascii/Hex convert in bash
- DOS command to format string to hex value
- How to convert file data to plain hex?
- 3 Answers 3
- Thread: Command needed to convert text to hex
- Command needed to convert text to hex
- Re: Command needed to convert text to hex
- Re: Command needed to convert text to hex
- Re: Command needed to convert text to hex
- Re: Command needed to convert text to hex
- Re: Command needed to convert text to hex
- Re: Command needed to convert text to hex
- Re: Command needed to convert text to hex
- Bookmarks
- Posting Permissions
Convert String to Hexadecimal on Command Line
Conversion hex string into ascii in bash command line
$ echo 54657374696e672031203220330 | xxd -r -p
Testing 1 2 3$
-r tells it to convert hex to ascii as opposed to its normal mode of doing the opposite
-p tells it to use a plain format.
bash ascii to hex
$ str="hello"
$ hex=$(xxd -pu $ echo "$hex"
6C6C6568A6F
$ hex=$(hexdump -e '"%X"' $ echo "$hex"
6C6C6568A6F
Careful with the ‘»%X»‘ ; it has both single quotes and double quotes.
Convert binary data to hexadecimal in a shell script
% xxd -l 16 -p /dev/random
193f6c54814f0576bc27d51ab39081dc
Convert hex string to ASCII string in Windows batch file
Use certutil tool, see certutil /? for more info.
setlocal enabledelayedexpansion
set "hex=4C6F67696300000000000000"
echo !hex!> temp.hex
call certutil -decodehex temp.hex str.txt >nul
set /p str=echo:
( del temp.hex & del str.txt )>nul
echo Your decoded string is:"!str!".
endlocal
exit /b 0
Is there any way to convert the hex code from string to hex colour which discord.py supports?
TypeError: Expected discord.Colour, int, or Embed.Empty
An int would suffice, no need for extra conversions.
@client.command()
async def testing(ctx):
# color = lgd.hexConvertor(colorCollection.find(<>,))
c = "0xFFFFFF"
int_colour = int(c,16)
await ctx.send(embed = discord.Embed(description = "testing",color = int_colour))
Ascii/Hex convert in bash
The reason is because hexdump by default prints out 16-bit integers, not bytes. If your system has them, hd (or hexdump -C ) or xxd will provide less surprising outputs — if not, od -t x1 is a POSIX-standard way to get byte-by-byte hex output. You can use od -t x1c to show both the byte hex values and the corresponding letters.
If you have xxd (which ships with vim), you can use xxd -r to convert back from hex (from the same format xxd produces). If you just have plain hex (just the ‘4161’, which is produced by xxd -p ) you can use xxd -r -p to convert back.
DOS command to format string to hex value
Forget about Peak Oil, what about Peak DOS? It’s time to look to the future. And the future is PowerShell.
How to convert file data to plain hex?
How to easily convert to/from plain machine-readable hexadecimal data (without any paddings/offsets/character view) with xdd or hexdump ? I’m tired of digging of some special format strings (and finding out that it suddenly starts wrapping lines after N characters or skip lines) or writing Perl one-liners every time. Why is it not as simple as base64 / base64 -d ?
3 Answers 3
If you get tired of writing this every time, create an alias.
I’m tired of looking at man page and gettings confused either by necessity to compose hexdump’s formt strings or by xxd’s «postscript» thing. (Is this «postscript» something about printers or about letters?)
@Vi, think of -p as «plain». I surmise the Postscript comment is because the Postscript language allows for in-line data (typically images) encoded exactly this way. So Postscript programmers may use xxd to convert binary images into a convenient form for embedding in a Postscript file.
How to easily convert to/from plain machine-readable hexadecimal data
$ xxd -plain test.txt > test.hex $ xxd -plain -revert test.hex test2.txt $ diff test.txt test2.txt $
$ xxd -plain test.txt > test.hex
This writes a hex encoding of the data in test.txt into new file test.hex. The -p or -plain option makes xxd use «plain» hex format with no spaces between pairs of hex digits (i.e. no spaces between byte values). This converts «abc ABC» to «61626320414243». Without the -p it would convert the text to a 16-bit word oriented traditional hexdump format, which is arguably easier to read but less compact and therefore less suitable as a transmission format and slightly harder to reverse.
$ xxd -plain -revert text.hex test2.txt
This uses the -r or -revert option for reverse operation. The -plain option is used again to indicate that the input hex file is in plain format.
I make the output filename different from the original filename so we can later compare the results with the original file.
The diff command outputs nothing — this means there is no difference between the original and reconstituted file contents.
I’m tired of digging of some special format strings
Use alias or declare functions in your .profile to create mnemonics so you don’t have to remember or dig about in man pages.
or just remember -plain and -revert .
Yes, there are new-line characters in the output. You want to avoid that. You can use the -c or -cols option to specify how long you want the output lines to be to attempt to avoid line-wrapping of the output. -c 0 gives the default length and the man page suggests 256 is the limit but it seems to work beyond that.
$ xxd -plain -cols 9999 test.txt > test.hex $ wc test.txt test.hex 121 880 4603 test.txt 1 1 9207 test.hex
The wc wordcount command tells us how many lines, words and characters are in each file.
So 121 lines (880 words, 4603 bytes) of ASCII text were encoded as 1 line of hex digits.
Thread: Command needed to convert text to hex
Skinny Soy Caramel Ubuntu
Join Date May 2006 Location Brooklyn, NY, USA Beans 629 —> Beans 629 Distro Ubuntu 7.10 Gutsy Gibbon
Command needed to convert text to hex
Does anyone know a standard unix/linux command to convert a text string to hexidecimal?
I’ve tried hexdump, but I need a single, unified hex string rather than the broken-up format hexdump gives.
If there is a command to do this without my having to parse hexdump output, that would be great. (I’d also be happy with perl code, though I’m less adept at perl than unix shell.)
Tea Glorious Tea!
Re: Command needed to convert text to hex
The problem is that string->hexadecimal can be done in a great number of ways depending on encoding.
I don’t know of any standard command, but it should be pretty easy to code in whatever language you prefer. Loop through all characters and then translate to integer which you then display as hexadecimal.
Quad Shot of Ubuntu
Re: Command needed to convert text to hex
If I understand you correctly you could use ghex2 and then save the hex as html, just be sure to save into a separate folder.
Ubuntu addict and loving it
Re: Command needed to convert text to hex
You could always hack up a small python program for it.
in_string = raw_input("Text: ") out_string = "" for c in in_string: out_string += hex(ord(c)).split("x")[1] + " " print(out_string)
Cookies and cream
Re: Command needed to convert text to hex
Ubuntu addict and loving it
Join Date Jan 2006 Location Philadelphia Beans 4,076 —> Beans 4,076 Distro Ubuntu 8.10 Intrepid Ibex
Re: Command needed to convert text to hex
here’s another solution in python (sample session shown below)
>>> import binascii >>> binascii.hexlify('blabla') '626c61626c61'
Gee! These Aren’t Roasted!
Re: Command needed to convert text to hex
Originally Posted by Metacarpal
Does anyone know a standard unix/linux command to convert a text string to hexidecimal?
I’ve tried hexdump, but I need a single, unified hex string rather than the broken-up format hexdump gives.
If there is a command to do this without my having to parse hexdump output, that would be great. (I’d also be happy with perl code, though I’m less adept at perl than unix shell.)
Skinny Soy Caramel Ubuntu
Join Date May 2006 Location Brooklyn, NY, USA Beans 629 —> Beans 629 Distro Ubuntu 7.10 Gutsy Gibbon
Re: Command needed to convert text to hex
Originally Posted by bogolisk
- Site Areas
- Settings
- Private Messages
- Subscriptions
- Who’s Online
- Search Forums
- Forums Home
- Forums
- The Ubuntu Forum Community
- Ubuntu Official Flavours Support
- New to Ubuntu
- General Help
- Installation & Upgrades
- Hardware
- Desktop Environments
- Networking & Wireless
- Multimedia Software
- Ubuntu Specialised Support
- Ubuntu Development Version
- Security
- Virtualisation
- Ubuntu Servers, Cloud and Juju
- Server Platforms
- Ubuntu Cloud and Juju
- Gaming & Leisure
- Emulators
- Wine
- Development & Programming
- Packaging and Compiling Programs
- Development CD/DVD Image Testing
- Ubuntu Application Development
- Ubuntu Dev Link Forum
- Programming Talk
- Repositories & Backports
- Ubuntu Backports
- Bug Reports / Support
- Ubuntu Backports
- System76 Support
- Apple Hardware Users
- Ubuntu Community Discussions
- Ubuntu, Linux and OS Chat
- Recurring Discussions
- Full Circle Magazine
- The Cafe
- Cafe Games
- Market
- Mobile Technology Discussions (CLOSED)
- Announcements & News
- Weekly Newsletter
- Membership Applications
- The Fridge Discussions
- Forum Council Agenda
- Forum Feedback & Help
- Request a LoCo forum
- Resolution Centre
- Ubuntu, Linux and OS Chat
- Other Discussion and Support
- Other OS Support and Projects
- Other Operating Systems
- Ubuntu/Debian BASED
- Debian
- MINT
- Arch and derivatives
- Fedora/RedHat and derivatives
- Mandriva/Mageia
- Slackware and derivatives
- openSUSE and SUSE Linux Enterprise
- Mac OSX
- PCLinuxOS
- Gentoo and derivatives
- Windows
- BSD
- Any Other OS
- Other Operating Systems
- Assistive Technology & Accessibility
- Art & Design
- Education & Science
- Documentation and Community Wiki Discussions
- Tutorials
- Outdated Tutorials & Tips
- Ubuntu Women
- Ubuntu LoCo Team Forums
- Americas LoCo Teams
- Argentina Team
- Software
- Hardware
- Comunidad
- Arizona Team — US
- Arkansas Team — US
- Brazil Team
- California Team — US
- Canada Team
- Centroamerica Team
- Chile Team
- Comunidad
- Hardware
- Software
- Instalaci�n y Actualizaci�n
- Colombia Team — Colombia
- Georgia Team — US
- Illinois Team
- Indiana — US
- Kentucky Team — US
- Maine Team — US
- Minnesota Team — US
- Mississippi Team — US
- Nebraska Team — US
- New Mexico Team — US
- New York — US
- North Carolina Team — US
- Ohio Team — US
- Oklahoma Team — US
- Oregon Team — US
- Pennsylvania Team — US
- Peru Team
- Texas Team — US
- Uruguay Team
- Utah Team — US
- Virginia Team — US
- West Virginia Team — US
- Argentina Team
- Asia and Oceania LoCo Teams
- Australia Team
- Bangladesh Team
- Hong Kong Team
- Myanmar Team
- Philippine Team
- Singapore Team
- Europe, Middle East, and African (EMEA) LoCo Teams
- Albania Team
- Catalan Team
- Portugal Team
- Egypt Team
- Georgia Team
- Ireland Team — Ireland
- Kenyan Team — Kenya
- Kurdish Team — Kurdistan
- Lebanon Team
- Morocco Team
- Saudi Arabia Team
- Sudan Team
- Tunisia Team
- Other Forums & Teams
- LoCo Archive
- Afghanistan Team
- Alabama Team — US
- Alaska Team — US
- Algerian Team
- Andhra Pradesh Team — India
- Austria Team
- Bangalore Team
- Bolivia Team
- Cameroon Team
- Colorado Team — US
- Connecticut Team
- Costa Rica Team
- Delhi Team
- Ecuador Team
- El Salvador Team
- Florida Team — US
- Galician LoCo Team
- Greek team
- Hawaii Team — US
- Honduras Team
- Idaho Team — US
- Iowa Team — US
- Jordan Team
- Kansas Team — US
- Libya Team
- Louisiana Team — US
- Maryland Team — US
- Massachusetts Team
- Michigan Team — US
- Missouri Team — US
- Montana Team — US
- Namibia Team
- Nevada Team — US
- New Hampshire Team — US
- New Jersey Team — US
- Northeastern Team — US
- Panama Team
- Paraguay Team
- Qatar Team
- Quebec Team
- Rhode Island Team — US
- Senegal Team
- South Carolina Team — US
- South Dakota Team — US
- Switzerland Team
- Tamil Team — India
- Tennessee Team — US
- Trinidad & Tobago Team
- Uganda Team
- United Kingdom Team
- US LoCo Teams
- Venezuela Team
- Wales Team
- Washington DC Team — US
- Washington State Team — US
- Wisconsin Team
- Yemen Team
- Za Team — South Africa
- Zimbabwe Team
- Americas LoCo Teams
- Other OS Support and Projects
- Ubuntu Official Flavours Support
Bookmarks
Bookmarks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts