Go package to simplify common use cases with argon2i
Go to file
2024-08-12 00:25:58 +02:00
decoder Initial commit 2024-07-24 23:44:50 +02:00
encoder Initial commit 2024-07-24 23:44:50 +02:00
.gitignore Initial commit 2024-07-24 23:44:50 +02:00
go.mod Set repository in go.mod 2024-08-12 00:22:43 +02:00
go.sum Update dependencies 2024-08-11 23:21:50 +02:00
LICENSE Add README.md and LICENSE 2024-07-24 23:48:36 +02:00
README.md Add README.md and LICENSE 2024-07-24 23:48:36 +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