public static String getOtpauthURL(String name, String issuer, String secret, HmacShaAlgorithm algorithm, String digits, String period) {
        Objects.requireNonNull(name, Required.ACCOUNT_NAME.toString());
        Objects.requireNonNull(secret, Required.SECRET.toString());
        Objects.requireNonNull(issuer, Required.ISSUER.toString());
        Objects.requireNonNull(algorithm, Required.ALGORITHM.toString());
        Objects.requireNonNull(digits, Required.DIGITS.toString());
        Objects.requireNonNull(period, Required.PERIOD.toString());
        
        var buffer = new StringBuilder();
        buffer.append("otpauth://totp/")
            .append(name)
            .append("?secret=")
            .append(RegExUtils.replaceAll(base32.encodeAsString(secret.getBytes(StandardCharsets.UTF_8)), "=", ""))
            .append("&algorithm=")
            .append(algorithm.getAlgorithm())
            .append("&issuer=")
            .append(issuer)
            .append("&digits=")
            .append(digits)
            .append("&period=")
            .append(period);
        
        String url = "";
        try {
            url = URLEncoder.encode(buffer.toString(), StandardCharsets.UTF_8.name());
        } catch (UnsupportedEncodingException e) {
            LOG.error("Failed to encode otpauth url", e);
        }
        
        return url;
    }
public static String getOtpauthURL ( String name , String issuer , String secret , HmacShaAlgorithm algorithm , String digits , String period ) { Objects . requireNonNull ( name , Required . ACCOUNT_NAME . toString ( ) ) ; Objects . requireNonNull ( secret , Required . SECRET . toString ( ) ) ; Objects . requireNonNull ( issuer , Required . ISSUER . toString ( ) ) ; Objects . requireNonNull ( algorithm , Required . ALGORITHM . toString ( ) ) ; Objects . requireNonNull ( digits , Required . DIGITS . toString ( ) ) ; Objects . requireNonNull ( period , Required . PERIOD . toString ( ) ) ; var buffer = new StringBuilder ( ) ; buffer . append ( "otpauth://totp/" ) . append ( name ) . append ( "?secret=" ) . append ( RegExUtils . replaceAll ( base32 . encodeAsString ( secret . getBytes ( StandardCharsets . UTF_8 ) ) , "=" , "" ) ) . append ( "&algorithm=" ) . append ( algorithm . getAlgorithm ( ) ) . append ( "&issuer=" ) . append ( issuer ) . append ( "&digits=" ) . append ( digits ) . append ( "&period=" ) . append ( period ) ; String url = "" ; try { url = URLEncoder . encode ( buffer . toString ( ) , StandardCharsets . UTF_8 . name ( ) ) ; } catch ( UnsupportedEncodingException e ) { LOG . error ( "Failed to encode otpauth url" , e ) ; } return url ; }
Generates a otpauth code to share a secret with a user

@param name The name of the account
@param issuer The name of the issuer
@param secret The secret to use
@param algorithm The algorithm to use
@param digits The number of digits to use
@param period The period to use

@return An otpauth url