473,467 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

The most efficient encryption method?

Nowadays, many site use encrypted resource ID, rather than plain
numeric ID, such as the following:
>http://www.youtube.com/watch?v=p_YMigZmUuk
"p_YMigZmUuk" will be mapped into a database unique ID (numeric, auto
increment).

What kind of encryption in PHP is the best in handling this job?

Thanks.

Aug 11 '06 #1
5 2327
On Fri, 11 Aug 2006 01:59:53 -0700, howachen wrote:
Nowadays, many site use encrypted resource ID, rather than plain
numeric ID, such as the following:
>>http://www.youtube.com/watch?v=p_YMigZmUuk

"p_YMigZmUuk" will be mapped into a database unique ID (numeric, auto
increment).

What kind of encryption in PHP is the best in handling this job?

Thanks.
I'm not sure that's quite "encryption", just that the ID uses a random
mixture of letters instead of a number.
Aug 11 '06 #2
*** ho******@gmail.com escribió/wrote (11 Aug 2006 01:59:53 -0700):
Nowadays, many site use encrypted resource ID, rather than plain
numeric ID, such as the following:
>>http://www.youtube.com/watch?v=p_YMigZmUuk
This is not encryption, it's just a random ID (or maybe a hash). The more
different chars you use, the shorter the string can be.
"p_YMigZmUuk" will be mapped into a database unique ID (numeric, auto
increment).
I'd just store it as string and unique key.
What kind of encryption in PHP is the best in handling this job?
You can calculate hashes with md5(), crc32() or sha1(), but you must be
aware that hashes are one-way: you can't get the original string back.

For random strings, you can use uniqid() or you can write a custom function
using mt_rand().
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 11 '06 #3
Alvaro G. Vicario wrote:
crc32()
I would avoid using crc32; it's not exactly an encryption.

Carl

Aug 11 '06 #4

Alvaro G. Vicario 寫é“:
*** ho******@gmail.com escribió/wrote (11 Aug 2006 01:59:53 -0700):
Nowadays, many site use encrypted resource ID, rather than plain
numeric ID, such as the following:
>http://www.youtube.com/watch?v=p_YMigZmUuk

This is not encryption, it's just a random ID (or maybe a hash). The more
different chars you use, the shorter the string can be.
"p_YMigZmUuk" will be mapped into a database unique ID (numeric, auto
increment).

I'd just store it as string and unique key.
What kind of encryption in PHP is the best in handling this job?

You can calculate hashes with md5(), crc32() or sha1(), but you must be
aware that hashes are one-way: you can't get the original string back.

For random strings, you can use uniqid() or you can write a custom function
using mt_rand().
well, to store md5() string in the datbase as the primary key is not a
good choice, since when performing table join, the speed is the trade
off. Also, the size of the row will become bigger.

Aug 12 '06 #5
I do this with session-based random sequences. It works as follows:
For each list of options (such as the options in a dropdown, or the
names of parameters you can pass to the page), you have an array of
"hashes". I quote the word hashes, because it is a salted hash, e.g. a
hash that also contains the session ID. This means that all hashes are
totally useless outside the current session. Because md5 hashes are
quite long, I compact them somewhat. Acutally, the hashes need not to be
based on the items themselves, and I usually just take an ordinal number
to base the hash on. So it is more of a random number than a hash.

If you want to code an option, id or name, just look it up in its array
in the session. If it is not there, create a new hash and add the
(option, hash) pair to the array in the session. this hash can be sent
to the client, while your real data remains on the server.

If you get a request from the client, just look up the hash to get the
real data again. If it is not there, fail gently. It means that either
someone has stored an old request and issues it again, or that the
session has expired. Or that you have made a programming error...

Example: say you want to send: <input type="radio" name="paymentmethod"
value="creditcard">
When both the name and the value get hashed, it would become something
like: <input type="radio" name="P5H0M" value="S8ND">
And in another session it could be: <input type="radio" name="PTOBW"
value="4JOC">

Any hacker that wants to break into and abuse a session from somebody
else now has to parse your generated pages during that same session to
be able to do much harm. Also, as the innocent user is still actively
using the session, he user will probably notice that something is wrong
and can inform the webmaster.

So it is just a measure to make a hacker's life more difficult.

Best regards

Alvaro G. Vicario wrote:
*** ho******@gmail.com escribió/wrote (11 Aug 2006 01:59:53 -0700):
>Nowadays, many site use encrypted resource ID, rather than plain
numeric ID, such as the following:
>>>http://www.youtube.com/watch?v=p_YMigZmUuk

This is not encryption, it's just a random ID (or maybe a hash). The more
different chars you use, the shorter the string can be.
>"p_YMigZmUuk" will be mapped into a database unique ID (numeric, auto
increment).

I'd just store it as string and unique key.
>What kind of encryption in PHP is the best in handling this job?

You can calculate hashes with md5(), crc32() or sha1(), but you must be
aware that hashes are one-way: you can't get the original string back.

For random strings, you can use uniqid() or you can write a custom function
using mt_rand().

Aug 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Palmieri | last post by:
Im using md5 to encrypt and decrypt plain text, this works fine... When i try to run the same function on a binary file, it does not decrypt correctly. Is there a way to encrypt binary files...
5
by: Jerry | last post by:
Hi, I am writing a Java Chatroom application that will implement encryption of messages using the RSA algorithm using the BigInteger class. It uses socket connections to exchange messages. I...
14
by: Ray Cassick \(Home\) | last post by:
Ok, time to ask the question here.. I have been battling over this one for sometime now and just have to ask it. I have created a few classes that I use to act a security keys. These classes get...
9
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike...
7
by: helmut woess | last post by:
Hi, has anybody knowledge about the safetyness of encrypting stored procs in SQL-Server 2005 using WITH ENCRYPTION? Or can they be hacked with the same old tools which exists for SQL 2000? ...
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
7
by: Mark Rae | last post by:
Hi, Picking your collective brains again, this time regarding the storage of the key used in symmetric encryption. Let's say you have a requirement to add encryption to a C# project, so you...
8
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't...
19
by: klenwell | last post by:
Another request for comments here. I'd like to accomplish something like the scheme outlined at this page here: http://tinyurl.com/3dtcdr In a nutshell, the form uses javascript to hash...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.