- Notifications
You must be signed in to change notification settings - Fork1
Hashing algorithms simplified (supports Argon2, Bcrypt, Scrypt, and PBKDF2)
License
NotificationsYou must be signed in to change notification settings
aldy505/phc-crypto
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Inspired byUpash, alsoimplementingPHC string format
Currently there are two options of using this package:
- Import all
- Import specific hash function
Bear in mind, these usage function might be changed in the near future.
- Bcrypt
- Argon2i & Argon2id
- PBKDF2
- Scrypt
For details regarding configs, please refer to their own directory.
package mainimport ("fmt""github.com/aldy505/phc-crypto")funcmain() {// Create a crypto instance// Change the scope name to your prefered hashing algorithm// Available options are: Bcrypt, Scrypt, Argon2, PBKDF2crypto,err:=phccrypto.Use(phccrypto.Scrypt, phccrypto.Config{})hash,err:=crypto.Hash("password123")iferr!=nil {fmt.Println(err)}fmt.Println(hash)// returns string ($scrypt$v=0$p=1,ln=32768,r=8$402ffb0b23cd3d3a$62daeae2ac...)verify,err:=crypto.Verify(hash,"password123")iferr!=nil {fmt.Println(err)}fmt.Println(verify)// returns boolean (true/false)}
package mainimport"github.com/aldy505/phc-crypto/scrypt"funcmain() {// Change the scope name to your prefered hashing algorithmhash,err:=scrypt.Hash("password123", scrypt.Config{})iferr!=nil {fmt.Println(err)}fmt.Println(hash)// returns string ($scrypt$v=0$p=1,ln=32768,r=8$402ffb0b23cd3d3a$62daeae2ac...)verify,err:=scrypt.Verify(hash,"password123")iferr!=nil {fmt.Println(err)}fmt.Println(verify)// returns boolean (true/false)}
Yes please! I'm still new to Go and I create this module (or package if you will) to help me fulfill a need on myproject. Feel free to refactor, add new feature, fix unknown bugs, and have fun!
MIT LicenseCopyright (c) 2024 Reinaldy Rafli and PHC Crypto collaboratorsPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
About
Hashing algorithms simplified (supports Argon2, Bcrypt, Scrypt, and PBKDF2)