Bitcoin Forum

Other => Off-topic => Topic started by: Alanay on July 17, 2016, 02:49:37 PM



Title: How to encrypt so outcome will look a certain way?
Post by: Alanay on July 17, 2016, 02:49:37 PM
I'm looking to find a method of encryption to encrypt a long list of characters and numbers. For example I could encrypt a list of 120 characters, including 0-9 numbers, and a-z characters. Then I want the outcome to always look something like "abc123def456". So an outcome might look like "ioe527kkl981", that is 3 letters followed by 3 numbers followed by 3 letters followed by 3 numbers.

Is this possible, and if so what's the easiest way to do it?

Thank you.


Title: Re: How to encrypt so outcome will look a certain way?
Post by: RHavar on July 17, 2016, 03:07:06 PM
This question might be better posted on stackoverflow than here, but yes it's possible. So when you encrypt something, most libraries are going to expose is as an array of bytes. So your real question actually distills down to an encoding/decoding one. But to get you started, what you'll want to do is encode the first X of the value in base A and then display them. Then then next Y of the value in base B and then display them. And then repeat. It's definitely going to be a lot trickier than just hex-encoding, so I'd think hard about if you really need it


Title: Re: How to encrypt so outcome will look a certain way?
Post by: Alanay on July 17, 2016, 03:19:16 PM
This question might be better posted on stackoverflow than here, but yes it's possible. So when you encrypt something, most libraries are going to expose is as an array of bytes. So your real question actually distills down to an encoding/decoding one. But to get you started, what you'll want to do is encode the first X of the value in base A and then display them. Then then next Y of the value in base B and then display them. And then repeat. It's definitely going to be a lot trickier than just hex-encoding, so I'd think hard about if you really need it

Thank you, I've moved my question on over to there. I'll spend some time today thinking more about this.


Title: Re: How to encrypt so outcome will look a certain way?
Post by: cloverme on July 19, 2016, 07:27:35 PM
I'm looking to find a method of encryption to encrypt a long list of characters and numbers. For example I could encrypt a list of 120 characters, including 0-9 numbers, and a-z characters. Then I want the outcome to always look something like "abc123def456". So an outcome might look like "ioe527kkl981", that is 3 letters followed by 3 numbers followed by 3 letters followed by 3 numbers.

Is this possible, and if so what's the easiest way to do it?

Thank you.

What you're talking about (the outcome) is called ciphertext. You would need to come up with your encryption scheme to allow you to encrypt or obfuscate your information in that way. However, with that kind of specific output, you're imparting a method to decrypt it as well.

If you're really that interested in a specific ciphertext pattern, my suggestion would be to hash the data, then write code that would record the original positions of the unsorted key.

Hash: 9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08

Your ciphertext: fdc 896 daf ....

Your keymap of positions: f2, d5, c12 ...

Lots of other solutions to do what you're looking to do.


Title: Re: How to encrypt so outcome will look a certain way?
Post by: dserrano5 on July 19, 2016, 09:09:05 PM
Hash: 9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08

Your ciphertext: fdc 896 daf ....

Your keymap of positions: f2, d5, c12 ...

That looks as just another layer of "encryption". And, what happens when you run out of letters? Because, you know, the hex alphabet has 10 digit and 6 letters. If you take 3 of each at a time, you're most probably going to run out of letters way before reaching the end of the string.

@OP: a good ciphertext should be indistinguishable from random data. Why try to make it look less random? You're not going to fool anyone with that approach.


Title: Re: How to encrypt so outcome will look a certain way?
Post by: cloverme on July 21, 2016, 12:34:15 AM

That looks as just another layer of "encryption". And, what happens when you run out of letters? Because, you know, the hex alphabet has 10 digit and 6 letters. If you take 3 of each at a time, you're most probably going to run out of letters way before reaching the end of the string.

@OP: a good ciphertext should be indistinguishable from random data. Why try to make it look less random? You're not going to fool anyone with that approach.

Completely agree, was throwing spaghetti at the wall... concepts of ROT13 mixed with offset and length values... ;D
No idea what OP was trying to do in reality, maybe a school exercise?

Wasn't motivated enough to don propeller hat and come up with full solution  8)


Title: Re: How to encrypt so outcome will look a certain way?
Post by: Shiroslullaby on July 25, 2016, 06:56:39 PM
Yeah this sounds like some sort of ciphertext.
You would have to create it yourself, since you have a very specific outcome that you want, but it wouldn't be too hard to come up with a basic cipher.

I can think about this more when I get home later, since Im only on a quick break at work.

Hannah_Montana >> 1 place
becomes
Ibo14.bj_13.pou114.b

H > I
a > b
n > o
n > 14.
a > b
h > j

M > 13.
o > p
n > o
t > u
a > 1
n > 14.
a > b

Theres probably a better solution to the numbers greater than the 9th place this is literally something I made in two mintues.