A bcrypt plugin for samp in Rust.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
include
pawn-tests
src
test
.gitignore
.travis.yml
Cargo.toml
LICENSE
README.md
bintray.json
makefile
pawn.json

README.md

SampBcrypt

Build Status sampctl-supported GitHub issues GitHub pull requests GitHub pull license

A bcrypt plugin for samp in Rust.

Installation

sampctl

If you are a sampctl user sampctl p 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,callback[],input[],cost)

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

    Example

     main(){
     	bcrypt_hash(0,"OnPassswordHash","text",12);
     }
    
     forward OnPassswordHash(playerid,hashid);
     public OnPassswordHash(playerid,hashid){
     	//hashid is id of stored result in memory
     }
  • bcrypt_get_hash(context,dest[],size = sizeof(hash))

    • context - id of stored result
    • dest[] - string to store hashed data
    • size - max size of dest string

    Example

    main(){
    	bcrypt_hash(0,"OnPassswordHash","text",12);
    }
    
    forward OnPassswordHash(playerid,hashid);
    public OnPassswordHash(playerid,hashid){
    	new dest[250];
    	bcrypt_get_hash(hashid,dest);
    	printf("hash : %s",dest);
    }
  • bcrypt_verify(playerid,callback[],input[],hash[])

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

    Example

     main(){
     	bcrypt_hash(0,"OnPassswordHash","text",12);
     }
    
     forward OnPassswordHash(playerid,hashid);
     public OnPassswordHash(playerid,hashid){
     	new dest[250];
     	bcrypt_get_hash(hashid,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){
     		//verfied
     	} else{
     		//hash doesn't match with text
     	}
     }
  • bcrypt_delete(context)

    • context - id of stored result

    Example

     main(){
     	bcrypt_hash(0,"OnPassswordHash","text",12);
     }
    
     forward OnPassswordHash(playerid,hashid);
     public OnPassswordHash(playerid,hashid){
     	new dest[250];
     	bcrypt_get_hash(hashid,dest);
     	bcrypt_delete(hashid); //must be called after usage of dest is over
     }