Go package to simplify common use cases with argon2i
Go to file
2023-09-13 11:47:58 +02:00
.github/workflows Add GitHub action to test package 2023-04-28 21:07:00 +02:00
argon2 Make Options, Encoder and Decoder properties public 2023-09-13 11:46:17 +02:00
.gitignore Add vendor to .gitignore 2022-12-04 02:34:55 +01:00
go.mod Fix issues during package import from remote repository 2022-12-04 14:10:30 +01:00
go.sum Initial commit 2022-12-04 02:18:05 +01:00
LICENSE Initial commit 2022-12-04 02:18:05 +01:00
README.md Update README.md Usages section 2023-09-13 11:46:18 +02:00

Argon2 utils

About

Utils to encrypt passwords using argon2

Usages

Hash password

    password := 'qwerty@123'
    // Create new encoder using default options
    encoder, _ := argon2.NewEncoder()
    hashedString, err = encoder.HashString(randomString)
    if err != nil {
        // handle error
    }

Compare password with hashed string

    // Create new decoder using default options
    decoder, _ := argon2.NewDecoder()
    match, err := decoder.CompareStringToHash(password, hashedString)
    if err != nil {
		// handle error
    }

Configure encoder or decoder options

Note that encoder and decoder inherited from the same base struct (argon2.Options). You can use the same argon2.OptFunc slice to configure both encoder and decoder.

    // Create new encoder using custom parameters
    encoder, options := argon2.NewEncoder(
        SetMemory(64 * 1024), // 64 bits
        SetParallelism(4),    // 4 concurrent actions
        SetKeyLength(32),     // key length
        SetSaltLength(32),    // salt length
        SetIterations(4),     // number of iterations
    )

Contributions

Euphoria Laxis GitHub

License

This project is under MIT License