randkey.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/python3
  2. # vcc/scripts/randkey.py
  3. #
  4. # This file is part of vcc.
  5. #
  6. # vcc is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # vcc is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with vcc. If not, see <https://www.gnu.org/licenses/>
  18. import argparse
  19. import random
  20. parser = argparse.ArgumentParser(description="Create random key", prog="randkey")
  21. parser.add_argument("-s", "--block-size", type=int, default=32, help="Specified the size of a block")
  22. args = parser.parse_args()
  23. table = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
  24. key = ""
  25. iv = ""
  26. for i in range(args.block_size):
  27. key += random.choice(table)
  28. iv += random.choice(table)
  29. print("Key: %s\nIV: %s" % (key, iv))