code: public static String generateBackupPassword() {
          final String alphabet = "123456789ABCDEFGHIJKLMNPQRSTUVWXYZ";
          final int len = alphabet.length();
          SecureRandom random = new SecureRandom();
          StringBuilder code = new StringBuilder(29);
  
          // 6 blocks
          for (int i = 0; i < 6; i++) {
  
              // of 4 chars
              for (int j = 0; j < 4; j++) {
                  char c = alphabet.charAt(random.nextInt(len));
                  code.append(c);
              }
  
              // dash after every block except the last one
              if (i != 5) {
                  code.append('-');
              }
          }
          return code.toString();
      }
docs: Generate a secure backup code.
  This code can be used to encrypt a secret key backup and follows the form described in XEP-0373 §5.3.
  
  @see <a href="https://xmpp.org/extensions/xep-0373.html#backup-encryption">
  XEP-0373 §5.4 Encrypting the Secret Key Backup</a>
  
  @return backup code