LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-06-2008, 10:21 AM   #16
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16

>For example, to get similar output to that of graemef (with alternate >order) you might do:

Seems to be doing what I'm looking for. How can I manipulate the output, say all caps or all lower case, things like that?

Mike

Last edited by mlewis; 04-06-2008 at 12:07 PM.
 
Old 04-06-2008, 01:53 PM   #17
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by mlewis View Post
How can I manipulate the output, say all caps or all lower case, things like that?
Code:
perldoc -f uc
perldoc -f lc
 
Old 04-06-2008, 04:41 PM   #18
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by osor View Post
Code:
perldoc -f uc
perldoc -f lc
I see, I have to change this in the code itself. Thanks.

Mike

Last edited by mlewis; 04-06-2008 at 06:26 PM.
 
Old 04-06-2008, 05:11 PM   #19
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
>perldoc -f uc
>perldoc -f lc

I see that the program is set to output all CAPS but there are many lower case characters in the output. It would be nice to have all options, output in all upper, lower or both. I thought I saw that somewhere when I was looking for the above uc/lc options.

Using this example as the average input string,
'W6ePreeSea24dSrp/a6ad?'

I would want the smallest to the largest permutations of the above string.

Anything A-F is a given as it's ascii code so no need to do anything but convert those digits to their ascii code. Only 0-9/a-z and G-Z need to be in the mix.
Mike

Last edited by mlewis; 04-06-2008 at 06:44 PM.
 
Old 04-06-2008, 08:29 PM   #20
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by mlewis View Post
I see that the program is set to output all CAPS but there are many lower case characters in the output.
The program is set to make all conversions from a character to it’s hex value so that the value contains only upper-case hex digits. So ‘n’ will always be translated to ‘6E’ and never translated to ‘6e’. But there can be lower case letters in the overall output, since one of the criteria was that lowercase a-f would possibly map to themselves. Thus, ‘b’ will be translated to ‘b’ or ‘62’. That’s where the lowercase letters come in. Of course if you wanted that to be upper-case as well, just throw in a uc (or if you are quoting, \U will do).
Quote:
Originally Posted by mlewis View Post
Using this example as the average input string,
'W6ePreeSea24dSrp/a6ad?'

I would want the smallest to the largest permutations of the above string.

Anything A-F is a given as it's ascii code so no need to do anything but convert those digits to their ascii code. Only 0-9/a-z and G-Z need to be in the mix.
I am not understanding your question here. Perhaps just show a small input string, and show the desired output, and explain how the desired output differs from what the snippet above outputs.

Also, I am wondering what the overall goal is here. If it is just mathematical curiosity, that’s fine, but if you are trying to solve a specific problem, perhaps there is a better way to do it.
 
Old 04-06-2008, 10:27 PM   #21
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
>The program is set to make all conversions from a character to it’s hex >value so that the value contains only upper-case hex digits.
>So ‘n’ will always be translated to ‘6E’ and never translated to ‘6e’.

Basically, everything 0-9 can be either the digit or it's ascii code.
Everything A-F/a-f is permutated.
G-Z/g-z always converted to their hex code.

I'm sorry that I have such a hard time explaining this . I was talking with a programming friend last night, telling him about this and it took a little time to explain it even face to face. I'm basically just trying to figure out how to generate various outputs based on fairly specific yet changing inputs.

>Of course if you wanted that to be upper-case as well, just throw in a >uc (or if you are quoting, >\U will do).

The output needs to be fully either upper or lower case. So far, in testing this, only lower case works. If I try to use uc, there are always some lower case chars in the output.

>but if you are trying to solve a specific problem, perhaps there
>is a better way to do it.

I am trying to solve a problem and I am also hoping to end up with a small tool which I can learn a little from, by changing variables here and there, perhaps being able to use it for generating unique combinations of codes.

Mike

Last edited by mlewis; 04-07-2008 at 07:36 AM.
 
Old 04-07-2008, 08:47 AM   #22
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by mlewis View Post
>The program is set to make all conversions from a character to it’s hex >value so that the value contains only upper-case hex digits.
>So ‘n’ will always be translated to ‘6E’ and never translated to ‘6e’.

Basically, everything 0-9 can be either the digit or it's ascii code.
Everything A-F/a-f is permutated.
G-Z/g-z always converted to their hex code.
permutated is not a word, and as I mentioned before what you want has nothing to do with permuting. Maybe you mean everything 0-9/A-F/a-f is either the digit or its ascii code?

If that's the case I think the map should be changed to this
Code:
map {
	/[A-Fa-f0-9]/ && [uc $_, hexstr($_)] ||
	# all other chars map to the hex rep. of their ASCII value
	[hexstr($_)]
} split//, $input;
Quote:
The output needs to be fully either upper or lower case. So far, in testing this, only lower case works. If I try to use uc, there are always some lower case chars in the output.
putting a uc in the map entry seems to work
Quote:
I am trying to solve a problem and I am also hoping to end up with a small tool which I can learn a little from, by changing variables here and there, perhaps being able to use it for generating unique combinations of codes.

Mike
Is the problem you are trying to solve a secret?

Last edited by ntubski; 04-07-2008 at 08:49 AM.
 
Old 04-07-2008, 09:32 AM   #23
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
>permutated is not a word

I've never used permutate or any variation of it in my life .

>as I mentioned before what you want has nothing to do with permuting.

Seems that different people call it different things because others have been saying just that, permutation. Doesn't matter what it's called, the real issue is my trying to explain what I need.

>Maybe you mean everything 0-9/A-F/a-f is either the digit or its ascii >code?

Yes, variations of the digit itself or it's ascii code value. At first I was using 0-9/A-F but you're right, 0-9/A-F/a-f would make more sense but the output would still remain all caps or all lower case.

>If that's the case I think the map should be changed to this

I'll give this a try, thanks very much for the input.

>putting a uc in the map entry seems to work

Strange. For me, it made all chars upper case but it left any c near the end of the result always lower case.

>Is the problem you are trying to solve a secret?

It's not a secret, I'm looking for a specific output based on an input.
 
Old 04-07-2008, 01:07 PM   #24
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by mlewis View Post
>permutated is not a word

I've never used permutate or any variation of it in my life .

>as I mentioned before what you want has nothing to do with permuting.

Seems that different people call it different things because others have been saying just that, permutation. Doesn't matter what it's called, the real issue is my trying to explain what I need.
I guess so, but I think at least some of the initial confusion over what you were asking for came from your use of the word permutation.

Quote:
Strange. For me, it made all chars upper case but it left any c near the end of the result always lower case.
Not sure how that would happen, with $input = "cc", I get
Code:
~/tmp$ ./comb.pl 
CC
C63
63C
6363
I guess you can always use tr on the output without touching the code (input = "aA", without the uc in the map):
Code:
~/tmp$ ./comb.pl 
aA
a41
61A
6141
~/tmp$ ./comb.pl | tr A-Z a-z 
aa
a41
61a
6141
~/tmp$ ./comb.pl | tr a-z A-Z
AA
A41
61A
6141
Quote:
It's not a secret, I'm looking for a specific output based on an input.
I meant what is the problem that you want to solve using this tool that gives the specific output. Or do you just like looking at long strings of hex ??
 
Old 04-07-2008, 02:51 PM   #25
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
>I meant what is the problem that you want to solve using this tool that >gives the specific output. Or do you just like looking at long strings of >hex?

This is something I'd like to understand, curiosity, and need to generate usable codes for an application.

The input would only be hex, using none of the following;
"*_+=:;@#~<>,.?/GHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz

The challenge is having a known output string like I've posted and trying to figure out what the hex only input (either all lc or uc) string would be to get that output. Using A-Fa-f0-9 currently, I am still seeing a mix of uc and lc in the output.

So far, it seems pretty straight forward, it just takes the input and outputs all combinations in the same order.

So, what if I now added a hash key I think it's called. Let's say another hex number that the program uses to calculate the output. How does a hash key work if I'm using the right term. Basically, something that I could throw in which would further obfuscate the output.

I hope that makes sense.

Mike
 
Old 04-07-2008, 06:22 PM   #26
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Using A-Fa-f0-9 currently, I am still seeing a mix of uc and lc in the output.
Well maybe you miscopied something somewhere, why don't you post the result of cat comb.pl and ./comb.pl (replacing comp.pl with whatever you called the file).

Quote:
So far, it seems pretty straight forward, it just takes the input and outputs all combinations in the same order.

So, what if I now added a hash key I think it's called. Let's say another hex number that the program uses to calculate the output. How does a hash key work if I'm using the right term. Basically, something that I could throw in which would further obfuscate the output.

I hope that makes sense.

Mike
There are many different hash functions, but there's probably a Perl module for it somewhere. However if your final goal is to reverse a cryptographic hash function you should know that those are specifically designed to prevent that sort of thing, and a program that simply tries all combinations will take a long time (as in thousands or millions of years)
 
Old 04-07-2008, 07:49 PM   #27
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
>However if your final goal is to reverse a cryptographic hash function >you should know that those are specifically designed to prevent that sort

Alright, it's time to explain this then. I've tried and tried not to get into specifics because I don't want anyone to think that this is about hacking or breaking codes for bad uses. But, making excuses gets you deeper and deeper into the toilet and then you do look like you're trying to do something bad . So, here's the story.

It starts with a piece of used hardware. I won't say which manufacturer it is because I don't want to potentially cause them problems by posting anything about their methods.

The hardware is no longer manufactured or supported so I can't get anything for it. In order for the machine to run, it needs a code entered at the console when it is installed. You are of course supposed to write that code down, which I had. I have two other's like it so I thought I had stored the code with those but it turns out I didn't and lost it.

Last week, after a good testing period to make sure all was good, I decided to simply default it rather than go into all of the settings and reconfigure, a lot easier to just default and start over. I'm sure you can guess the rest.

Now, I still have my code but, it's in the registry, already installed on the machine and it's in code such as I've posted. The code is entered as all lc or uc hex.

I also have a backup of the registry but the darn thing is in binary and I can't seem to find a way of converting that to an ascii file that I can simply re-import into the machine then could see my code again.
Actually, I can see it in ascii using Linux mc but I don't know how to convert it to ascii otherwise.

At some point, when I turn it off or have to reset something a little deeper which overwrites the registry, that will kill the machine and that will be a terrible thing for me. It took me a long time to find this used at a price I could afford.

So, the bottom lime is, I'm only trying to figure out the hex input string so that I can re-enter it at some point. That's the honest to goodness truth of the matter.

And, I've also now become interested in this tool we're creating as something I might be able to use for my own code generating uses down the road once I better understand how reliable these types of things can be.

By the way, I get Out of Memory errors with longer strings.

Mike

Last edited by mlewis; 04-07-2008 at 08:45 PM.
 
Old 04-07-2008, 10:06 PM   #28
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Actually, I can see it in ascii using Linux mc but I don't know how to convert it to ascii otherwise.
If you can see it in ascii, can't you just write it down on a piece of paper? This doesn't sound like it's obfuscated/encrypted at all. Does mc mean Midnight Commander?
 
Old 04-07-2008, 10:59 PM   #29
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
>If you can see it in ascii, can't you just write it down on a piece of >paper? This doesn't sound like it's obfuscated/encrypted at all.

Oh my god, what a nightmare but I finally got it all back and working along with a backup of my code. Actually, many copies.

I won't get into it all but I finally got the backup registry working after a lot of messing around.

>Does mc mean Midnight Commander?[/QUOTE]

Yes, it's one of my favorite tools .

So, I'm still interested in this little program if anyone else is. I'd like to understand how hash codes work by including one in this little piece of code. Wish a hash code, then as tiny as it is, it would still make a great code generator would it not?

I know I can download a thousand of them but this is cooler as it's sort of community made.

Mike
 
Old 04-07-2008, 11:39 PM   #30
mlewis
Member
 
Registered: Mar 2006
Posts: 187

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by ntubski View Post
If you can see it in ascii, can't you just write it down on a piece of paper? This doesn't sound like it's obfuscated/encrypted at all. Does mc mean Midnight Commander?
Sorry, I forgot to explain this but yes the file can be viewed using mc but I can't manipulate it in any other way. I found that I was able to see the file using windows commander which is how I finally managed to convert it to text.

It looks like a binary file to everything but mc on both linux and win.

Mike
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[bash] ASCII to HEX and hex to ascii ////// Programming 17 05-08-2018 09:55 PM
hex to ascii and ascii to hex ilnli Programming 7 08-31-2007 11:55 AM
display in hex + perl + non ASCII characters kshkid Programming 4 02-06-2007 04:48 PM
How do i write to a serial port (modem) in ascii or hex directly? Taliesin.duchaos Linux - Networking 6 04-21-2006 08:31 AM
Binary to Hex Ascii converter carboncopy Slackware 1 05-28-2004 09:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration