I've to give the client ID to my customers. As this number will be used in a
third part app, and I only rely on this number for checking the user's
existence (I can't change the third part app), I'd like not to give the flat
number, but an "encoded"
number that let me check if the code is valid.
Let's say client ID = 723
I'd like to have a code quite simple to provide by phone, without any
strange things like @^~... for simple users...
The best things would be an algorithm to crypt the code with a private key
known only by me, and being able to decrypt the code.
I've tried mcrypt_encrypt( ) , but it's an uncknown function (I'm under
Apache, XP).
Cheers 4 8896
Well Bob,
Considering you can't use mcrypt, which kinda stinks, you could also just
make the string appear encoded with bas64_encode and base64_decode. No key
required but it appears encrypted to inexperienced peepers. :-\
-Kyle
"Bob Bedford" <be******@YouKn owWhatToDoHereh otmail.com> wrote in message
news:41******** *************** @news.sunrise.c h... I've to give the client ID to my customers. As this number will be used in a third part app, and I only rely on this number for checking the user's existence (I can't change the third part app), I'd like not to give the flat number, but an "encoded" number that let me check if the code is valid.
Let's say client ID = 723 I'd like to have a code quite simple to provide by phone, without any strange things like @^~... for simple users...
The best things would be an algorithm to crypt the code with a private key known only by me, and being able to decrypt the code.
I've tried mcrypt_encrypt( ) , but it's an uncknown function (I'm under Apache, XP).
Cheers
"Kyle Hayes" <ky**@digitaley eon.com> a écrit dans le message de news: Bd************* *******@adelphi a.com... Well Bob, Considering you can't use mcrypt, which kinda stinks, you could also just make the string appear encoded with bas64_encode and base64_decode. No key required but it appears encrypted to inexperienced peepers. :-\ -Kyle
I've tried, but ask the user, by phone, to enter something like McxFasfxcr
isn't the worst thing I can do.
I'm thinking of something like:
$1 = $ID*45-3
$2 = $ID+2*17
Then the code I provide is $1."S".$2
For decoding and testing, I'll only make the opposite calculation, and if
the calculation1 == calculation2, then the ID should be OK.
But I'd like to avoid such S in the middle.
"Bob Bedford" <be******@YouKn owWhatToDoHereh otmail.com> wrote in message
news:41******** *************** @news.sunrise.c h... I've to give the client ID to my customers. As this number will be used in
a third part app, and I only rely on this number for checking the user's existence (I can't change the third part app), I'd like not to give the
flat number, but an "encoded" number that let me check if the code is valid.
Let's say client ID = 723 I'd like to have a code quite simple to provide by phone, without any strange things like @^~... for simple users...
The best things would be an algorithm to crypt the code with a private key known only by me, and being able to decrypt the code.
I've tried mcrypt_encrypt( ) , but it's an uncknown function (I'm under Apache, XP).
Do something like this: combine the client ID with a secret password, then
get the MD5 hash. To check whether it's valid, just loop through all the
possible client IDs and calculate the hash. If there's a match then it's
valid. md5() is quite fast on modern CPUs. As long as your clients number in
thousands rather then millions, the operation should complete in fraction of
a second.
To make it a little friendlier, you can perhaps use just the last few
characters of the hash and convert it to a decimal with hexdec().
"Bob Bedford" <be******@YouKn owWhatToDoHereh otmail.com> wrote in message news:<41******* *************** *@news.sunrise. ch>... I've to give the client ID to my customers. As this number will be used in a third part app, and I only rely on this number for checking the user's existence (I can't change the third part app), I'd like not to give the flat number, but an "encoded" number that let me check if the code is valid.
Let's say client ID = 723 I'd like to have a code quite simple to provide by phone, without any strange things like @^~... for simple users...
Perhaps...
<?php
function EncryptClientId ($id)
{
return substr(md5($id) , 0, 8).dechex($id);
}
function DecryptClientId ($id)
{
$md5_8 = substr($id, 0, 8);
$real_id = hexdec(substr($ id, 8));
return ($md5_8==substr (md5($real_id), 0, 8)) ? $real_id : 0;
}
$id = 723;
$enc_id = EncryptClientId ($id);
echo $enc_id."\n";
echo DecryptClientId ($enc_id);
?>
--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Newbie |
last post by:
How would I modify this form
to encode *all* the characters
in the 'source' textarea to the
'%xx' format & place result
code into the 'output' textarea?
(cross browser compatable)
Any help is appreciated.
Regards.
|
by: Damir Hakimov |
last post by:
Hi *!
I found a strange bug in base64.encode and decode, when I try to encode
- decode a file 1728512 bytes lenth.
Is somebody meet with this? I don't attach the file because it big, but
can send to private.
Which solution for transfer file (binary data) via string-only object?
Damir.
|
by: AR |
last post by:
I would like to know more about the Encode/Decode feature available
within MS Access.
This is what I have read from Microsoft Office OnLine:
"The simplest method of protection is to encode the database. Encoding
a database compacts the database file and helps protect it from being
read by a word processor."
Is this recommended as a best practice? What is the impact on
|
by: jtfaulk |
last post by:
I need to encode some information on the server side using ASP.NET with
C#; sending via HTTP to a client side application, that needs to be
decoded in an MFC C++ application.
I'm not sure if I can encode something using:
C#: System.Security.Cryptography (to encode)
and
|
by: 7stud |
last post by:
s1 = "hello"
s2 = s1.encode("utf-8")
s1 = "an accented 'e': \xc3\xa9"
s2 = s1.encode("utf-8")
The last line produces the error:
---
Traceback (most recent call last):
| |
by: mario |
last post by:
Hello!
i stumbled on this situation, that is if I decode some string, below
just the empty string, using the mcbs encoding, it succeeds, but if I
try to encode it back with the same encoding it surprisingly fails
with a LookupError. This seems like something to be corrected?
$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
on darwin
|
by: glacier |
last post by:
I use chinese charactors as an example here.
"'\\xc4\\xe3\\xba\\xc3\\xc2\\xf0'"
My first question is : what strategy does 'decode' use to tell the way
to seperate the words. I mean since s1 is an multi-bytes-char string,
how did it determine to seperate the string every 2bytes or 1byte?
My second question is: is there any one who has tested very long mbcs
|
by: J Peyret |
last post by:
Well, as usual I am confused by unicode encoding errors.
I have a string with problematic characters in it which I'd like to
put into a postgresql table.
That results in a postgresql error so I am trying to fix things with
<string>.encode
he Company�s ticker
Trying for an encode:
|
by: anonymous |
last post by:
1 Objective to write little programs to help me learn German. See code
after numbered comments. //Thanks in advance for any direction or
suggestions.
tk
2 Want keyboard answer input, for example:
answer_str = raw_input(' Enter answer ') Herr Üü
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |