├── .formatter.exs ├── .gitignore ├── .tool-versions ├── README.md ├── config └── config.exs ├── lib └── pdg.ex ├── mix.exs ├── pdg └── test ├── pdg_test.exs └── test_helper.exs /.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where third-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | pdg-*.tar 24 | 25 | proguard-dictionary.txt 26 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | elixir 1.10.2 2 | erlang 21.1 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pdg 2 | 3 | Inspired by https://github.com/PureWriter/proguard-dict 4 | 5 | ## Installation 6 | 7 | 1. Download pdg, put it where you want to generate random proguard dictionary file or your any bin folder 8 | 2. Just run it 9 | * run `pdg` 10 | * use `./pdg` if not put in bin path 11 | 12 | ## Command line args 13 | 14 | 1. --name or -n for file name (default proguard-dictionary.txt) 15 | 2. --from or -f for start length (default 6) 16 | 3. --to or -t for end length (default 30) 17 | 18 | Example: `pdg --name halo.txt -f 7 -t 70` -------------------------------------------------------------------------------- /config/config.exs: -------------------------------------------------------------------------------- 1 | # This file is responsible for configuring your application 2 | # and its dependencies with the aid of the Mix.Config module. 3 | use Mix.Config 4 | 5 | # This configuration is loaded before any dependency and is restricted 6 | # to this project. If another project depends on this project, this 7 | # file won't be loaded nor affect the parent project. For this reason, 8 | # if you want to provide default values for your application for 9 | # third-party users, it should be done in your "mix.exs" file. 10 | 11 | # You can configure your application as: 12 | # 13 | # config :pdg, key: :value 14 | # 15 | # and access this configuration in your application as: 16 | # 17 | # Application.get_env(:pdg, :key) 18 | # 19 | # You can also configure a third-party app: 20 | # 21 | # config :logger, level: :info 22 | # 23 | 24 | # It is also possible to import configuration files, relative to this 25 | # directory. For example, you can emulate configuration per environment 26 | # by uncommenting the line below and defining dev.exs, test.exs and such. 27 | # Configuration from the imported file will override the ones defined 28 | # here (which is why it is important to import them last). 29 | # 30 | # import_config "#{Mix.env()}.exs" 31 | -------------------------------------------------------------------------------- /lib/pdg.ex: -------------------------------------------------------------------------------- 1 | defmodule Pdg.CLI do 2 | def main(args) do 3 | options = [ 4 | switches: [from: :integer, to: :integer, name: :string], 5 | aliases: [f: :from, t: :to, n: :name] 6 | ] 7 | {opts,_,_}= OptionParser.parse(args, options) 8 | text = generate("", "W", "w", opts) 9 | |> generate("O", "0", opts) 10 | |> generate("O", "o", opts) 11 | |> generate("OO", "o", opts) 12 | |> generate("O", "o0", opts) 13 | |> generate("I", "l", opts) 14 | |> generate("L", "l", opts) 15 | |> generate("I", "1", opts) 16 | |> generate("I", "1l", opts) 17 | |> generate("K", "k", opts) 18 | |> generate("U", "u", opts) 19 | |> generate("X", "x", opts) 20 | |> generate("S", "s", opts) 21 | |> generate("M", "m", opts) 22 | |> generate("C", "c", opts) 23 | |> generate("Z", "z", opts) 24 | |> String.trim_trailing 25 | File.write(opts[:name] || "proguard-dictionary.txt", text) 26 | |> IO.inspect 27 | end 28 | 29 | defp generate(acc, first, second, args) do 30 | from = args[:from] || 6 31 | to = args[:to] || 30 32 | generate(acc, first, second, from, to) 33 | end 34 | 35 | defp generate(acc, first, second, from, to) do 36 | count = Enum.random(from..to) 37 | acc <> generate_child(count, first, second, "") 38 | end 39 | 40 | defp generate_child(count, first, second, acc) do 41 | if count > 0 do 42 | length = String.length(second) 43 | other = if length > 1 do 44 | generate_random("", second, count) 45 | else 46 | String.duplicate(second, count) 47 | end 48 | generate_child(count-1, first, second, acc <> first <> other <> "\n") 49 | else 50 | acc 51 | end 52 | end 53 | 54 | defp generate_random(acc, second, count) do 55 | if count > 0 do 56 | generate_random( 57 | acc <> String.slice(second, Enum.random(0..String.length(second)-1), 1), 58 | second, count-1) 59 | else 60 | acc 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /mix.exs: -------------------------------------------------------------------------------- 1 | defmodule Pdg.MixProject do 2 | use Mix.Project 3 | 4 | def project do 5 | [ 6 | app: :pdg, 7 | version: "0.1.0", 8 | elixir: "~> 1.10", 9 | start_permanent: Mix.env() == :prod, 10 | deps: deps(), 11 | escript: [main_module: Pdg.CLI] 12 | ] 13 | end 14 | 15 | # Run "mix help compile.app" to learn about applications. 16 | def application do 17 | [ 18 | extra_applications: [:logger] 19 | ] 20 | end 21 | 22 | # Run "mix help deps" to learn about dependencies. 23 | defp deps do 24 | [ 25 | # {:dep_from_hexpm, "~> 0.3.0"}, 26 | # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} 27 | ] 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /pdg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ionull/proguard-dictionary-generator/d06fd145f1fa44ba92b6f8c47c80da2573d7d7a7/pdg -------------------------------------------------------------------------------- /test/pdg_test.exs: -------------------------------------------------------------------------------- 1 | defmodule PdgTest do 2 | use ExUnit.Case 3 | doctest Pdg 4 | 5 | test "greets the world" do 6 | assert Pdg.hello() == :world 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | --------------------------------------------------------------------------------