/    Sign up×
Community /Pin to ProfileBookmark

Is Not BigInt Or VARCHAR (40) Not Big Enough To House sha1?

I want to know if BigInt is enough in size. I have created a registration.php where the user gets emailed an account activation link to click to verify his email so his account gets activated.

Account Activation Link is in this format:

[code=php]
$account_activation_link =
“http://www.”.$site_domain.”/”.$social_network_name.”/activate_account.php?primary_website_email=”.$primary_website_email.”&account_activation_code=”.$account_activation_code.””;
[/code]

Account Activation Code is in this format:

$account_activation_code = sha1( (string) mt_rand(5, 30)); //Type Casted the INT to STRING on the 1st parameter of sha1 as it needs to be a STRING.

Now, the following link got emailed: [url]http://www.myssite.com/folder/[email protected]&account_activation_code=22d200f8670dbdb3e253a90eee5098477c95c23d[/url]

Note the account activation code that got generated by sha1: 22d200f8670dbdb3e253a90eee5098477c95c23d

But in my mysql db, in the “account_activation_code” column, I only see: “22”. The rest of the activation code is missing. Why is that ? The column is set to BigInt. Is not that enough to house the Sha1 generated code ? What is your suggestion ?
I changed mysql column type to VARCHAR(40) and then VARCHAR(160) and even to BINARY(40) but no luck.
The sha1 generates the account activation code to 40 digits in the account activation link that gets emailed to the user but the account_activation_code mysql column does not hold that 40 digit value. Only holds the first 2 or 3 digits. What is wrong ?
Using php 5.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@benanamenDec 14.2017 — Question has already been answered under OP's alt user name here http://forums.devnetwork.net/viewtopic.php?f=1&t=144938
Copy linkTweet thisAlerts:
@rootDec 14.2017 — It is a fairly simple question to answer, all you do is search the internet for the known length or make one and measure it and then you will know the answer.
Copy linkTweet thisAlerts:
@ginerjmDec 14.2017 — How do you plan on making a bigint handle alphabetic chars?

Any kind of encryption produces some pretty large (string) fields. So why not just set it to varchar(255) and not worry about it?
Copy linkTweet thisAlerts:
@NogDogDec 14.2017 — bigint only holds an integer, it just allows big ones. When you tried to load the [i]string[/i] "22d200f8670dbdb3e253a90eee5098477c95c23d" (which though it looks like a hexadecimal number it is actually just a string in this context), something -- probably your PHP code somewhere -- tried to convert it into an integer, was okay with the first two characters, than ran into a letter, and stopped trying.
<i>
</i>21:15 $ php -a
Interactive shell

php &gt; $test = '22ab123cd456';
php &gt; echo $test;
22ab123cd456
php &gt; $test2 = (int) $test;
php &gt; echo $test2;
22
php &gt; ^C

In any case, I'd recommend making the activation code column larger, just in case: varchar only actually uses the number of bytes for each string being stored plus a few "bookkeeping" bytes on top of that, so you might as well make it varchar(255) or such, in case you ever decide to use something different.
Copy linkTweet thisAlerts:
@site-developerauthorDec 17.2017 — Thank you GinerJm and NogDog,

I switched column to VarChar(255) now. It was working lastnight at Varchar(40). 40 digits anyway.
Copy linkTweet thisAlerts:
@site-developerauthorDec 17.2017 — Question has already been answered under OP's alt user name here http://forums.devnetwork.net/viewtopic.php?f=1&t=144938[/QUOTE]

Thanks for pointing the link out Benny.

I had forgotten I had opened a thread there.

Don't forget to tell others here that you been helping me out on another forum too, even though not on this particular thread:

http://forums.devshed.com/php-development-5/bigint-varchar-40-house-sha1-979632.html

And since you managed to trail me all over the net but failed to trail me on Stack OverFlow then here I am again:

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0ahUKEwjy-aXytZHYAhUEJ5QKHRFBCqIQFgg3MAI&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F47798679%2Fis-not-bigint-enough-to-house-sha1&usg=AOvVaw3Pm2bB7GzUtzgec8yzrPl8

I only opened threads in other forums plus this one when I reached a deadend at Stack OverFlow.

I will let you find me on other forums under this same Username and more. A cat & mouse game. So, come & catch me Tom. Jerry is running ....
Copy linkTweet thisAlerts:
@ginerjmDec 17.2017 — Now that you have shown yourself to be a real Boor, I hope that you don't find the need to post here anymore. It's fun to help out those in need, but not when they show what a jerk they can be. Besides - your last 'real' post didn't make sense anyway.

Good luck being you!
×

Success!

Help @site-developer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...