Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

My plugin that does cryptographic hash functions identification is re…

…ady to go...
  • Loading branch information...
commit ba3dac5f1cb0dad5faaace3fe170cc139edb2a65 1 parent e88db42
@digit4lfa1l digit4lfa1l authored
Showing with 61 additions and 0 deletions.
  1. +38 −0 lib/DDG/Goodie/CryptHashCheck.pm
  2. +23 −0 t/CryptHashCheck.t
View
38 lib/DDG/Goodie/CryptHashCheck.pm
@@ -0,0 +1,38 @@
+package DDG::Goodie::CryptHashCheck;
+# ABSTRACT: Identifies cryptographic hash function type.
+
+use DDG::Goodie;
+
+zci is_cached => 1;
+zci answer_type => 'crypt_hash_check';
+
+triggers start => "hash","md5","sha";
+
+primary_example_queries 'hash 624d420035fc9471f6e16766b7132dd6bb34ea62';
+secondary_example_queries 'md5 1f9b59a2390bb77d2c446837d6aeab067f01b05732735f47099047cd7d3e9f85';
+description 'Identifies cryptographic hash function type.';
+name 'CryptHashCheck';
+code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/CryptHashCheck.pm';
+category 'computing_tools';
+topics 'cryptography';
+
+attribution github => ['https://github.com/digit4lfa1l', 'digit4lfa1l'];
+
+
+handle remainder => sub {
+ my ($md5) = /^[0-9a-f]{32}$/i;
+ return 'This is MD5 cryptographic hash function.' if $md5;
+ my ($sha1) = /^[0-9a-f]{40}$/i;
+ return 'This is SHA-1/40 cryptographic hash function.' if $sha1;
+ my ($sha224) = /^[0-9a-f]{56}$/i;
+ return 'This is SHA-2/224 cryptographic hash function.' if $sha224;
+ my ($sha256) = /^[0-9a-f]{64}$/i;
+ return 'This is SHA-2/256 cryptographic hash function.' if $sha256;
+ my ($sha384) = /^[0-9a-f]{96}$/i;
+ return 'This is SHA-2/384 cryptographic hash function.' if $sha384;
+ my ($sha512) = /^[0-9a-f]{128}$/i;
+ return 'This is SHA-2/512 cryptographic hash function.' if $sha512;
+ return;
+};
+
+1;
View
23 t/CryptHashCheck.t
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+use DDG::Test::Goodie;
+
+zci answer_type => 'crypt_hash_check';
+zci is_cached => 1;
+
+ddg_goodie_test(
+ [qw(
+ DDG::Goodie::CryptHashCheck
+ )],
+ 'hash 5c0847eccfaeabf4a0207d42a2986992' => test_zci('This is MD5 cryptographic hash function.'),
+ 'md5 ecaceaca62d6c47190ed6c6f94a298f28a46450fda0bd1ec8fc64bc4a7a8cd436791a35f3c4e339b7ae480c1b751f1c1' => test_zci('This is SHA-2/384 cryptographic hash function.'),
+ 'sha b1d7eb51d4372c505446abca04835a101275e498' => test_zci('This is SHA-1/40 cryptographic hash function.'),
+ 'hash 6286e0a5cbc030f7b2d105f594ae0afb9105c92175c6b07ff454734c23cd0bddfed77639fe59b68a70b8c78af27657f611cbe89c27f7a47b978fa9449808c19f' => test_zci('This is SHA-2/512 cryptographic hash function.'),
+ 'md5 a8a35ab9036388fd42fe1d73d93ede7ec604044ba4753259fafbf718' => test_zci('This is SHA-2/224 cryptographic hash function.'),
+
+);
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.