Giter Club home page Giter Club logo

samp-bcrypt's Introduction

SampBcrypt

Build sampctl GitHub issues GitHub pull requests GitHub pull license

A bcrypt plugin for samp in Rust.

Installation

sampctl

If you are a sampctl user sampctl install Sreyas-Sreelal/samp-bcrypt

OR

  • Download suitable binary files from releases for your operating system
  • Add it your plugins folder
  • Add samp_bcrypt to server.cfg or samp_bcrypt.so (for linux)
  • Add samp_bcrypt.inc in includes folder

Building

  • Clone the repo

    git clone https://github.com/Sreyas-Sreelal/samp-bcrypt.git

  • Setup testing server

    make setup

  • Build using makefile

    make release for release builds

    make debug for debug builds

  • Run the tests

    make run

API

  • bcrypt_hash(playerid, const callback[], const input[], cost, const args[] = "", {Float, _}:...)

    • playerid - id of the player
    • callback[] - callback to execute after hashing
    • input[] - string to hash
    • cost - work factor (4 - 31)
    • args[] - custom arguments

    Example

     main()
     {
     	bcrypt_hash(0, "OnPassswordHash", "text", BCRYPT_COST);
     }
    
     forward OnPassswordHash(playerid);
     public OnPassswordHash(playerid)
     {
     	// Hashing completed
     }
  • bcrypt_get_hash(dest[], size = sizeof(hash))

    • dest[] - string to store hashed data
    • size - max size of dest string

    Example

     main()
     {
     	bcrypt_hash(0, "OnPassswordHash", "text", BCRYPT_COST);
     }
    
     forward OnPassswordHash(playerid);
     public OnPassswordHash(playerid)
     {
     	new dest[BCRYPT_HASH_LENGTH];
     	bcrypt_get_hash(dest);
     	printf("hash : %s", dest);
     }
  • bcrypt_verify(playerid, const callback[], const input[], const hash[], const args[] = "", {Float, _}:...)

    • playerid - id of the player
    • callback[] - callback to execute after hashing
    • input[] - text to compare with hash
    • hash[] - hash to compare with text
    • args[] - custom arguments

    Example

     main()
     {
     	bcrypt_hash(0, "OnPassswordHash", "text", BCRYPT_COST);
     }
    
     forward OnPassswordHash(playerid);
     public OnPassswordHash(playerid)
     {
     	new dest[BCRYPT_HASH_LENGTH];
     	bcrypt_get_hash(dest);
     	bcrypt_verify(playerid, "OnPassswordVerify", "text", dest);
     }
    
     forward OnPassswordVerify(playerid, bool:success);
     public OnPassswordVerify(playerid, bool:success)
     {
     	// success denotes verifying was successful or not
     	
     	if (success)
     	{
     		// Verified
     	} 
     	else
     	{
     		// Hash doesn't match with text
     	}
     }
  • bcrypt_set_thread_limit(value)

    • value - number of worker threads at a time

    Example

     main()
     {
     	bcrypt_set_thread_limit(3);
     }

samp-bcrypt's People

Contributors

adib-yg avatar dextromethorphanum avatar dobbysgamertag avatar patrickgtr avatar se8870 avatar sreyas-sreelal avatar vince0789 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

samp-bcrypt's Issues

[error]: callback => InvalidHash

Hello, I have problem with bcrypt_verify

Here is my code:

Dialog:LoginPlayer(playerid, response, listitem, inputtext[])
{
	if(!response)
	{
		log("Player cancelled login", _s("Player", PlayerData[playerid][E_PLAYER_NAME]));
		return 1;
	}

	bcrypt_verify(playerid, "OnPasswordVerify", inputtext, PlayerData[playerid][E_PLAYER_PASSWORD]);

	return 1;
}

E_PLAYER_PASSWORD is hash ( char(60) inside sql )
https://prnt.sc/oyrspx

Console: [SampBcrypt] [error]: OnPasswordVerify => InvalidHash("$2y$12$Sue6j3FxY8EF9qzTzA9KL.um9BxV8NvIGVA5yviHiIvPdXeR0MUd")

Running bcrypt alongside JIT causing server crash

As the title says, trying to run this plugin alongside JIT Plugin is causing the server to crash on startup.

[log-core] fatal signal '11' (SIGSEGV) watched  

logs/log-core.log

[10/26/21 20:45:21] [ERROR] signal 11 (SIGSEGV) catched; shutting log-core down (errno: 0, signal code: 128, exit status: 0)

SAMPCTL

WARN: failed to ensure package github.com/Sreyas-Sreelal/samp-bcrypt:0.2.2: failed to ensure dependency from cache: remote repository is empty

WARN: failed to ensure package github.com/Sreyas-Sreelal/samp-bcrypt: failed to ensure dependency from cache: remote repository is empty

ensuring from .json or via sampctl p install - doesn't work

Unable to Load in Linux

Loading plugin: samp_bcrypt.so
Failed (/lib/i386-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by plugins/samp_bcrypt.so))

Create an another release

If u could please add an release with #4 since every time we download a new dependencie we have to manually update the .inc file for bcyrpt

Cannot execute callback

I currently use the newest version (0.3.2). Tested this on Windows 10.

main()
{
	bcrypt_hash(0, "testCallback", "password", 12);
}

forward testCallback(playerid);
public testCallback(playerid)
{
	new string[200];
	bcrypt_get_hash(string);

	print(string);
}

server_log.txt:

[SampBcrypt] [error]: *Cannot execute callback "testCallback"
$2y$12$lPesaPOT0fgPNOmIIboCS.DJxpJDT2rTVZpwfNjnj0.038Xeb2dBu

A small mistake

WARN: failed to ensure plugin github.com/Sreyas-Sreelal/samp-bcrypt:0.4.0 failed to get plugin github.com/Sreyas-Sreelal/samp-bcrypt:0.4.0 from net: resource matcher 'samp-bcrypt-windows-x86.zip' does not match any release assets from '[ samp-bcrypt-linux-x86.zip samp_bcrypt-windows-x86.zip]'

Rename please

Funny that this project has a similar problem :)

Salt?

Hi,

I'm trying to reproduce the results of hashing with bcrypt with this plugin and outside with a Python script (https://zetcode.com/python/bcrypt/), but I get different results as the Python implementation requires a salt.

How is salt used in this plugin?

sampctl...

Please release the const corrected version or fix it somehow inside pawn.json cuz SAMPCTL users still get (warning) literal array/string passed to a non-const parameter

OnDialogResponse

Doesn't work with inputtext in OnDialogResponse or it is just me?

new hash[BCRYPT_HASH_LENGTH];
printf("%s", inputtext);

bcrypt_hash(playerid, "OnPasswordHash", inputtext, BCRYPT_COST);

format(hash, 65, "%s", bcrypt_get_hash(hash));
printf("1: %s", bcrypt_get_hash(hash));
printf("2: %s", hash);

printf with inputtext shows player's password
printf 1 null
printf 2 null

Not backwards compatible

The new release adds optional parameters to the callback (not debating the usefulness of this here). However, while the format specifier is optional in the include, it is required in the plugin. This means you can't just swap out the plugin and use an existing mode with it; you are forced to recompile. Probably not a problem for most people, but the fifth argument should be optional in the plugin as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.