cimmer
asked on
PHP 2 way string encryption with character limit
I have a string that may vary in length somewhere between 20 and 80 characters and will only contain a-z, dashes, periods and 0-9
EXAMPLE:
35023001-new-abcdesdaleabc defgreputa tionabcdef ment.com
Its basically the productid-itemtype-domainn ame
Most of these come well under 50 characters in total length but a domain name can be ordered with up to 63 characters (plus the .com) in length alone.
This example string is 54 characters long. The problem is that I need to store this as 50 characters or less and I need to be able to reverse the encoding or encryption so I can read it without knowing what it is or entering it initially to be hashed.
Basically I need something like like what the php function base64_encode and base64_decode does but with a resulting character length limit of 50...
Is this possible?
EXAMPLE:
35023001-new-abcdesdaleabc
Its basically the productid-itemtype-domainn
Most of these come well under 50 characters in total length but a domain name can be ordered with up to 63 characters (plus the .com) in length alone.
This example string is 54 characters long. The problem is that I need to store this as 50 characters or less and I need to be able to reverse the encoding or encryption so I can read it without knowing what it is or entering it initially to be hashed.
Basically I need something like like what the php function base64_encode and base64_decode does but with a resulting character length limit of 50...
Is this possible?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can I ask why you need to make a long character string into a 50 character string? There may be a better way to skin this cat.
Where will the encode / decode algorithm run?
With a-z, 0-9 and two punctuations you get 38 unique characters. There is no case-sensitivity (all lower case) and no blank to be used, right?
Thanks and regards, ~Ray
Where will the encode / decode algorithm run?
With a-z, 0-9 and two punctuations you get 38 unique characters. There is no case-sensitivity (all lower case) and no blank to be used, right?
Thanks and regards, ~Ray
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Right... a-z, 0-9 and two punctuations = 38 unique characters. There is no case-sensitivity (all lower case) and no blank to be used...
well I basically make my own Order Item ID which is sent to an API to place an order for a domain name. The API limits the length of this ID at 50 and then returns whether order was successful or not. This is the only way I can pass what it is I actually ordered so that I can later read the items on the orders from their system. The 50 limit is set in stone on the API. This problem only occurs when a long domain name is ordered which is like 1 out of 100 orders.
Their documentation didnt mention this limit in it so now Im trying to work with the system in place by just compressing the id when passed and uncompressing when read.
well I basically make my own Order Item ID which is sent to an API to place an order for a domain name. The API limits the length of this ID at 50 and then returns whether order was successful or not. This is the only way I can pass what it is I actually ordered so that I can later read the items on the orders from their system. The 50 limit is set in stone on the API. This problem only occurs when a long domain name is ordered which is like 1 out of 100 orders.
Their documentation didnt mention this limit in it so now Im trying to work with the system in place by just compressing the id when passed and uncompressing when read.
ASKER
i think im just gonna cut the id off at 50... then add some code after the order is successful to look up the full domain name. Extra work for no reason.. =( Thanks for the info though. Good Stuff.
ASKER
I tried it on a few different string from 8 in length up to 80 and they all got larger.