Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Shaiya > Shaiya Private Server > Shaiya PServer Guides & Releases
You last visited: Today at 00:10

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Security]Bcrypt hash algorithm in Shaiya

Discussion on [Security]Bcrypt hash algorithm in Shaiya within the Shaiya PServer Guides & Releases forum part of the Shaiya Private Server category.

Reply
 
Old   #1
 
[ADM]Sky's Avatar
 
elite*gold: 0
Join Date: Jul 2016
Posts: 91
Received Thanks: 243
[Security]Bcrypt hash algorithm in Shaiya

Hi!

Example of implementing the BCrypt algorithm for Shaiya servers.

Step 1
Quote:
EXEC sp_configure 'CLR ENABLED' , '1'
GO
RECONFIGURE
GO
ALTER DATABASE PS_UserData SET TRUSTWORTHY ON
GO
Step 2
Execute the file BCrypt_assembly.sql, which is located below.


Step 3 (BCrypt-Function)
Quote:
CREATE FUNCTION [dbo].[BCrypt](@password [nvarchar](4000), @rounds [int])
RETURNS [nvarchar](4000) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [BCrypt].[BCryptPackage.UserDefinedFunctions].[BCrypt]
GO
EXEC sys.sp_addextendedproperty @name=N'AutoDeployed', @value=N'yes' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'BCrypt'
GO
EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFile', @value=N'BCryptAssembly' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'BCrypt'
GO
EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFileLine', @value=813 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'BCrypt'
This step is optional, because the hash itself will be created by the site, but thanks to this function, you can perform verification.

Step 4(CheckPassword function)
Quote:
CREATE FUNCTION [dbo].[CheckPassword](@password [nvarchar](4000), @hashed [nvarchar](4000))
RETURNS [bit] WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [BCrypt].[BCryptPackage.UserDefinedFunctions].[CheckPassword]
GO
EXEC sys.sp_addextendedproperty @name=N'AutoDeployed', @value=N'yes' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',
@level1name=N'CheckPassword'
GO
EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFile', @value=N'BCryptAssembly' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',
@level1name=N'CheckPassword'
GO
EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFileLine', @value=820 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',
@level1name=N'CheckPassword'
If you get an error, you need to change the database compatibility level.



Step 5
Now run it to check.
Quote:
DECLARE @passwd VARCHAR(60)
DECLARE @crypted_passwd VARCHAR(60)
SET @passwd = 'weakPassword1234'
select @crypted_passwd = dbo.Bcrypt('weakPassword1234',10)
print @crypted_passwd
-- Check if the passwords match
select dbo.CheckPassword(@passwd,@crypted_passwd)
Сheck result:


Step 6
Execute the file usp_Try_GameLogin_Taiwan.sql, which is located below.

Сheck result:




Very important:
PHP once made the Bcrypt function, but the first versions of it did not work correctly. This is why they started changing the prefix at the beginning of the hash to indicate that it is a new version, but this is not suitable for us to check in the database, so we will do this little trick.



PHP Code:
$pw 'test9080';

$PwHash password_hash($pwPASSWORD_BCRYPT);
echo 
$PwHash;
echo 
"<br>";

$PwHash str_replace("$2y$""$2a$"$PwHash);
echo 
$PwHash


I wish you the best of everything!
Attached Files
File Type: rar BCrypt_assembly.rar (23.8 KB, 52 views)
File Type: rar usp_Try_GameLogin_Taiwan.rar (1.0 KB, 42 views)
[ADM]Sky is offline  
Thanks
9 Users
Old 04/28/2020, 21:50   #2
 
[BSG]Reeya's Avatar
 
elite*gold: 30
Join Date: Mar 2020
Posts: 63
Received Thanks: 45
Very Nice Release, thanks Sky
[BSG]Reeya is offline  
Thanks
1 User
Old 04/29/2020, 00:04   #3
 
elite*gold: 0
Join Date: Apr 2020
Posts: 12
Received Thanks: 2
Perfectly gret
bannedwrong1 is offline  
Thanks
1 User
Old 04/29/2020, 01:18   #4
 
elite*gold: 0
Join Date: Mar 2019
Posts: 98
Received Thanks: 10
Thanks you working
admkraken81 is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
[Just another graph-related algorithm] Kruskal`s algorithm
07/25/2012 - CO2 Programming - 11 Replies
(Scroll down for the code if you aren`t interested in my wall of text.) Okay, my previous post on Dijkstra`s algorithm didn`t really get the attention it was supposed to get, but I`m still starting a trend out of this. What exactly? I will be posting general purpose algorithms from time to time, as I truly believe that this is one of the most fundamental and important aspect of being a good coder : knowing the basic algorithms (lol?). If anyone can provide a way of implementing this in a CO...



All times are GMT +1. The time now is 00:10.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.