Hi all,
In my application, I'm trying to encrypt a certain string and send it back to the user by email. Currently i'm using SHA(1). I tried SHA and MD5 also. The problem with these is they give a really long (40 characters) encrypted string. The users are freaking out seeing such a big string. To make things worst, i lao have to append thier company name to it which make it even bigger. So i need an alorithm that can generate a smaller string like 6, 8 or evejn 10 is fine.
I browsed around and forund somethng called Crypt(). But this returns a binary output and hence sometimes it has special characters in it. Other than this fact this works very well.
Can anyone help me with an algorithm that returns a small string and is not binary(i do not want any special characters in it.) Numbers and alphabets only.
Any help is appreciated. I have been searching a lot. Thanks.
-- Vamsi.
Php Encryption Algorithms -- Help Needed!!!
Moderator: General Moderators
-
vamsinadella
- Forum Newbie
- Posts: 15
- Joined: Fri Dec 22, 2006 6:05 pm
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
You should be aware that the shorter the result is, the more likely it will match another you have already generated. If you don't really care about the raised collision rate you can choose other hashes such as CRC.
crc32()
crc32()
-
vamsinadella
- Forum Newbie
- Posts: 15
- Joined: Fri Dec 22, 2006 6:05 pm
stereofrog,
Thank you for responding.
I'm trying to encrypt a string. For ex. say we have a string "This is an example string" and i have to send this string to a user. But i do not want to send it as it is so i want to encrypt it. to achieve that we can use many php functions like SHA(), SHA1(), MD5() Crypt(). BUt the problem (my problem) with these functions is they either give you a long 40 or a 32 character string or it is binary - meaning it spits out special characters every now and then.
I 'm looking for an encryption algorithm that is not too long (may be 10 - 12 characters) and do not have any special characters. Does that make sense??? I'm sorry i'm trying my best to put my problem as clear as possible.
Feyd,
First of all, thanks you for the help. Yes i do realize that the shorter it is the more likely it will match. But the users are bent upon getting a shorter string. I tried crc32(). It is giving me just numbers....Is it the way it is supposed to work??? i mean that is ok. But it is spitting a '-' sign sometimes. Is there a way to avoid this? Thanks. Any other functions in PHP you have in mind?
-- Vamsi
Thank you for responding.
I'm trying to encrypt a string. For ex. say we have a string "This is an example string" and i have to send this string to a user. But i do not want to send it as it is so i want to encrypt it. to achieve that we can use many php functions like SHA(), SHA1(), MD5() Crypt(). BUt the problem (my problem) with these functions is they either give you a long 40 or a 32 character string or it is binary - meaning it spits out special characters every now and then.
I 'm looking for an encryption algorithm that is not too long (may be 10 - 12 characters) and do not have any special characters. Does that make sense??? I'm sorry i'm trying my best to put my problem as clear as possible.
Feyd,
First of all, thanks you for the help. Yes i do realize that the shorter it is the more likely it will match. But the users are bent upon getting a shorter string. I tried crc32(). It is giving me just numbers....Is it the way it is supposed to work??? i mean that is ok. But it is spitting a '-' sign sometimes. Is there a way to avoid this? Thanks. Any other functions in PHP you have in mind?
-- Vamsi
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Re: Php Encryption Algorithms -- Help Needed!!!
Boy, it doesn't take much to freak them out.vamsinadella wrote:The users are freaking out seeing such a big string.
http://panamajack.aatraders.com/readblog/19d98afc3721302b70501ac278a35672b6feac6ef4d7a61277be10391032a22ffd37cfd3e77b1e0431a380ae6d97e724
It contains alot of info and created using mcrypt.
Re: Php Encryption Algorithms -- Help Needed!!!
Enlighten me panama jack... how much info can you put in that string? What kind of stuff do you have in there? This might be a solution to a problem I am having.AKA Panama Jack wrote:Boy, it doesn't take much to freak them out.vamsinadella wrote:The users are freaking out seeing such a big string.They would go completely catatonic if they saw a URL from my sites blogging system.
http://panamajack.aatraders.com/readblog/19d98afc3721302b70501ac278a35672b6feac6ef4d7a61277be10391032a22ffd37cfd3e77b1e0431a380ae6d97e724
It contains alot of info and created using mcrypt.