Libxcrypt compatible go library.
Find a file
2026-02-04 02:23:44 -06:00
.gitignore First commit 2024-09-07 18:53:27 -05:00
bcrypt.go Update base64 algorithms to include a decode function, and add unit testing. Moved SHA1 algorthm to its own function as the original algorithm in libxcrypt is not able to encode all data lengths correctly. Added blowfish/bcrypt algorithm that should be libxcrypt compatible. 2026-02-03 16:32:45 -06:00
blowfish.go Update base64 algorithms to include a decode function, and add unit testing. Moved SHA1 algorthm to its own function as the original algorithm in libxcrypt is not able to encode all data lengths correctly. Added blowfish/bcrypt algorithm that should be libxcrypt compatible. 2026-02-03 16:32:45 -06:00
go.mod Update modules 2026-02-04 00:11:22 -06:00
go.sum Update modules 2026-02-04 00:11:22 -06:00
gost_yes_crypt.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00
LICENSE.txt Corrected spelling for SCrypt, added helper functions to make working with the package easier. 2025-01-03 11:29:57 -06:00
md5_crypt.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00
nt_hash.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00
passwd.go Update base64 algorithms to include a decode function, and add unit testing. Moved SHA1 algorthm to its own function as the original algorithm in libxcrypt is not able to encode all data lengths correctly. Added blowfish/bcrypt algorithm that should be libxcrypt compatible. 2026-02-03 16:32:45 -06:00
passwd_test.go Update base64 algorithms to include a decode function, and add unit testing. Moved SHA1 algorthm to its own function as the original algorithm in libxcrypt is not able to encode all data lengths correctly. Added blowfish/bcrypt algorithm that should be libxcrypt compatible. 2026-02-03 16:32:45 -06:00
pbkdf1_sha1_crypt.go Update base64 algorithms to include a decode function, and add unit testing. Moved SHA1 algorthm to its own function as the original algorithm in libxcrypt is not able to encode all data lengths correctly. Added blowfish/bcrypt algorithm that should be libxcrypt compatible. 2026-02-03 16:32:45 -06:00
README.md Other case fixes. 2026-02-04 02:23:44 -06:00
s_crypt.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00
sha256_crypt.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00
sha512_crypt.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00
sun_md5.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00
utils.go Update base64 algorithms to include a decode function, and add unit testing. Moved SHA1 algorthm to its own function as the original algorithm in libxcrypt is not able to encode all data lengths correctly. Added blowfish/bcrypt algorithm that should be libxcrypt compatible. 2026-02-03 16:32:45 -06:00
utils_test.go Update base64 algorithms to include a decode function, and add unit testing. Moved SHA1 algorthm to its own function as the original algorithm in libxcrypt is not able to encode all data lengths correctly. Added blowfish/bcrypt algorithm that should be libxcrypt compatible. 2026-02-03 16:32:45 -06:00
yes_crypt.go Fix incorrectly referenced password in string hash with salt functions. 2025-02-25 12:43:49 -06:00

go-passwd

This is a libxcrypt compatible password hashing library for the Go language. The passwords generated with this library is fully compatible with libxcrypt which can be used to generate or test passwords in use by software such as MySQL or the Linux shadow system.

Install

go get github.com/grmrgecko/go-passwd

Docs

https://pkg.go.dev/github.com/grmrgecko/go-passwd

Example

package main

import (
	"github.com/grmrgecko/go-passwd"
	"log"
)

func main() {
	result, err := passwd.SCheckPassword("$y$j9T$Q3N1jZa3Cp.yNINNDt5dDgYkHU7k$9o7WJJB5F.tTEhZdz6T6LMWY/0C3JkhvmcNyUPvUBlC", "Test")
	if err != nil {
		log.Fatalln(err)
	}

	if result {
		log.Println("Password confirmed, saving new password.")

		pw := passwd.NewSHA512CryptPasswd()
		hash, err := pw.SHashPassword("New Password!!!")
		if err != nil {
			log.Fatalln(err)
		}
		log.Println("The new password hash to save is:", hash)
	}
}

Example output:

$ ./test
2024/09/07 18:42:35 Password confirmed, saving new password.
2024/09/07 18:42:35 The new password hash to save is: $6$4Eu/l5e.otcRj0rJ$YAlwxJD9pZY9.Z2TjseCbkXiUIrFU2AXh9DPEm5Z1SagxP..xaQCsz7jAgfW4nmUbLh.o23pEZGvvxPCLltf11

Known issues

  • It is possible to generate password hashes that are incompatible with libxcrypt by setting a large round count. This may be mitigated in the future by adding an option to disable compatibility and otherwise require compatible parameters to be set.