azarat — 2010-11-29T11:33:05-05:00 — #1
I need to encrypt something but I do not want any special character in the encryption output. Only letters and numbers. Is there any cipher that can achieve this?
blue1 — 2010-11-29T12:30:40-05:00 — #2
Is there a reason why you're looking to change the encryption method rather than your approach? It's so pointless to put encryption and charset in the same sentence, think about your reasoning about this request.
Hint: if it's a database insert problem, take a look at PDO.
aleksejs — 2010-11-30T08:42:26-05:00 — #3
hex value perhaps?
aleksejs — 2010-11-30T08:36:08-05:00 — #4
urlencode the output of cipher
and when received
urldecode url parameter and then decrypt
azarat — 2010-11-30T08:32:29-05:00 — #5
Well I have some URL parameters that I do not want to be too obvious to the users, and to make the URL a bit more clean than having a lot of special characters up there.
azarat — 2010-11-30T08:40:12-05:00 — #6
Yes, yes, I do know that it would work without any problems. But I do like to get something a bit cleaner than for example
in the URL.
azarat — 2010-11-30T09:05:46-05:00 — #7
That's pretty clever.
Though is there any way that I can encrypt via cipher, take take the hex value of that. And then decrypt that again?
Using bin2hex and hexdec doesn't work.
aleksejs — 2010-11-30T09:14:35-05:00 — #8
You need bin2hex, there is no built in hex2bin though - so you use:
$binary_representation = pack('H*', $hexvalue);
azarat — 2010-11-30T09:16:03-05:00 — #9
awesome! thanks a lot mate!
blue1 — 2010-11-30T10:59:54-05:00 — #10
1.) It's a bad idea to use GET method to propagate (larger set of) data.
2.) GET method has a limit on amount of data you can send, use POST.
3.) Hexing something inflates the data by the factor of 2, you'll hit the limit of the GET method extremely fast and you'll wonder how your thing won't decrypt.
4.) Using hexed data to obfuscate something is generally bad idea because it's extremely easy to notice it.
aleksejs — 2010-12-01T02:02:25-05:00 — #11
I agree with first three statements. The last one I think does not apply here, since he passes output of cipher - hexing serves here merely as an encoding not obfuscation.
azarat — 2010-12-01T06:42:15-05:00 — #12
Thanks for the responses.
As I'm only encrypting numbers, and a number like 12345678910111212345678910111212389172398716273091238091 returns: 58e03717907c3cdc13df1d619e0422949c5b70ea189ecf78
and that's a number I really don't expect to get up to, and I think that I should be able to use the GET method in this case.
blue1 — 2010-12-01T07:53:22-05:00 — #13
I'm assuming you're passing some sort of an ID trough the URL and you don't want users to guess numbers by changing the query string.
Well, don't you think that encrypting / decrypting or/and hexing the number is a little too extreme? As I said, change of approach to your problem might be a better solution.
leelong — 2010-12-01T14:17:39-05:00 — #14
base64_encode() may be faster if all u need is just to get rid of 'special character in the encryption output'