Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cbuschka/go-spring-password-encoder
Spring compatible password encoders written in golang
https://github.com/cbuschka/go-spring-password-encoder
bcrypt golang java password sha256 spring spring-boot
Last synced: 1 day ago
JSON representation
Spring compatible password encoders written in golang
- Host: GitHub
- URL: https://github.com/cbuschka/go-spring-password-encoder
- Owner: cbuschka
- License: mit
- Created: 2021-11-12T19:43:52.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-10T08:08:32.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T17:41:42.438Z (5 months ago)
- Topics: bcrypt, golang, java, password, sha256, spring, spring-boot
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# go-spring-password-encoder
[![Build](https://github.com/cbuschka/go-spring-password-encoder/workflows/build/badge.svg)](https://github.com/cbuschka/go-spring-password-encoder) [![Latest Release](https://img.shields.io/github/release/cbuschka/go-spring-password-encoder.svg)](https://github.com/cbuschka/go-spring-password-encoder/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/cbuschka/go-spring-password-encoder)](https://goreportcard.com/report/github.com/cbuschka/go-spring-password-encoder) [![License](https://img.shields.io/github/license/cbuschka/go-spring-password-encoder.svg)](https://github.com/cbuschka/go-spring-password-encoder/blob/main/license.txt)
### Spring compatible password encoders written in golang
## Usage
Add entry to go.mod file:
```
[...]go 1.16
require (
github.com/cbuschka/go-spring-password-encoder v1.0.0
[...]
)
```import the package fromn within your code:
```
import "github.com/cbuschka/go-spring-password-encoder"
```### SHA256PasswordEncoder (called StandardPasswordEncoder by spring)
Hint: This password encoder is considered legacy and too weak.
#### Hash and encode password
```
encoder := spring_password_encoder.NewDefaultSHA256PasswordEncoder()encodedPasswordHash, err := encoder.Encode("asdfasdf")
```#### Compare plain text password with hashed password
```
encoder := spring_password_encoder.NewDefaultSHA256PasswordEncoder()encodedPasswordHash, err := encoder.Encode("asdfasdf")
```See [sha256 password encoder test](./sha256_password_encoder_test.go)
### BCryptPasswordEncoder
#### Hash and encode password
```
encoder := spring_password_encoder.NewDefaultBCryptPasswordEncoder()encodedPasswordHash, err := encoder.Encode("asdfasdf")
```#### Compare plain text password with hashed password
```
encoder := spring_password_encoder.NewDefaultBCryptPasswordEncoder()encodedPasswordHash, err := encoder.Encode("asdfasdf")
```See [bcrypt password encoder test](./bcrypt_password_encoder_test.go)
## License
Copyright (c) 2021 by [Cornelius Buschka](https://github.com/cbuschka).
[MIT](./license.txt)