def main(**kwargs): """Name That Hash - Instantly name the type of any hash! Github:\n https://github.com/hashpals/name-that-hash From the creator of RustScan and Ciphey. Follow me on Twitter!\n https://twitter.com/bee_sec_san Example usage:\n nth --text '5f4dcc3b5aa765d61d8327deb882cf99'\n nth --file hash\n nth --text '5f4dcc3b5aa765d61d8327deb882cf99' --greppable\n Note: Use single quotes ' as inverted commas " do not work well on Linux.\n """ no_args = True for i in kwargs.values(): if i: no_args = False break if no_args: with click.Context(main) as ctx: click.echo(main.get_help(ctx)) exit(0) # Load the verbosity, so that we can start logging set_logging(kwargs) logging.debug(kwargs) # Banner handling if not kwargs["accessible"] and not kwargs["no_banner"] and not kwargs[ "greppable"]: logging.info("Running the banner.") banner() # nth = the object which names the hash types nth = hash_namer.Name_That_Hash(hashes.prototypes) # prettifier print things :) pretty_printer = prettifier.Prettifier(kwargs) hashChecker = check_hashes.HashChecker(kwargs, nth) logging.debug( "Initialised the hash_info, nth, and pretty_printer objects.") output = [] if kwargs["text"]: hashChecker.single_hash(kwargs["text"]) output = hashChecker.output elif kwargs["file"]: hashChecker.file_input(kwargs["file"]) output = hashChecker.output elif kwargs["extreme"]: output = hashChecker.find_all_hashes() if kwargs["greppable"]: print(pretty_printer.greppable_output(output)) else: pretty_printer.pretty_print(output)
def compute_hashes_for_api(chash: List, args: dict = {}): # nth = the object which names the hash types nth = hash_namer.Name_That_Hash(hashes.prototypes) hashChecker = check_hashes.HashChecker(args, nth) for i in chash: hashChecker.single_hash(i) return hashChecker.output
def compute_hashes_for_api(chash: [str], args: dict = {}): # nth = the object which names the hash types nth = hash_namer.Name_That_Hash(hashes.prototypes) # prettifier print things :) pretty_printer = prettifier.Prettifier(args, api=True) hashChecker = check_hashes.HashChecker(args, nth) for i in chash: hashChecker.single_hash(i) return hashChecker.output
def api_return_hashes_as_json(chash: [str], args: dict = {}): """ Using name-that-hash as an API? Call this function! Given a list of hashes of strings return a list of json of all hashes in the same order as the input """ # nth = the object which names the hash types nth = hash_namer.Name_That_Hash(hashes.prototypes) # prettifier print things :) pretty_printer = prettifier.Prettifier(args, api=True) hashChecker = check_hashes.HashChecker(args, nth) output = [] for i in chash: hashChecker.single_hash(i) output.append(hashChecker.output) return pretty_printer.greppable_output(output)