# Produce the user and password for Traefik in Docker Compose with Java

**URL:** https://community.traefik.io/t/produce-the-user-and-password-for-traefik-in-docker-compose-with-java/15293
**Category:** Community Contributions
**Tags:** traefik-v2
**Created:** [August 1, 2022, 4:50pm UTC](https://community.traefik.io/t/produce-the-user-and-password-for-traefik-in-docker-compose-with-java/15293 "2022-08-01T16:50:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Milano2022](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/milano2022/32/5539_2.png) [@Milano2022](https://community.traefik.io/u/Milano2022)
#### Post date: [August 1, 2022, 4:50pm UTC](https://community.traefik.io/t/produce-the-user-and-password-for-traefik-in-docker-compose-with-java/15293/1 "2022-08-01T16:50:02Z")

</div>

I created a small Java script that produces the user and password for Traefik in Docker Compose.  
My little program is a good replacement for htpasswd.  
I make the code available to the community so if anyone wants to improve it they can do it.  
I hope it is useful.

```auto
public class TraefikPassword {

    public static void main(String[] args) throws NoSuchAlgorithmException {
        System.out.println("Password production for Traefik in Docker Compose by Federico Galimberti");
        String userTraefik = "user";
        String passwordTraefik = "password";
        System.out.println(
                "traefik.http.middlewares.auth.basicauth.users: " +
                        userTraefik +
                        ":" +
                        Md5Crypt.md5Crypt(passwordTraefik.getBytes()).replace("$", "$$")
        );
    }
	
	// Output
	// traefik.http.middlewares.auth.basicauth.users: user:$$1$$ifRtujSw$$iFT0QyOjaz0waXQRsPgjj.
	
}

```

Good day
