langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
34
Task/MD5/Nemerle/md5.nemerle
Normal file
34
Task/MD5/Nemerle/md5.nemerle
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Console;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
using Nemerle.Collections;
|
||||
using Nemerle.Collections.NCollectionsExtensions;
|
||||
|
||||
module Md5
|
||||
{
|
||||
HashMD5(input : string) : string
|
||||
{
|
||||
BitConverter.ToString
|
||||
(MD5.Create().ComputeHash(Encoding.Default.GetBytes(input))).Replace("-", "").ToLower()
|
||||
}
|
||||
|
||||
IsValidMD5(text : string, hash : string) : bool
|
||||
{
|
||||
HashMD5(text) == hash.ToLower()
|
||||
}
|
||||
|
||||
Main() : void
|
||||
{
|
||||
def examples = ["The quick brown fox jumped over the lazy dog's back", "", "a", "abc", "message digest",
|
||||
"abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
||||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];
|
||||
def hashes = ["e38ca1d920c4b8b8d3946b2c72f01680", "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"0cc175b9c0f1b6a831c399e269772661", "900150983cd24fb0d6963f7d28e17f72",
|
||||
"f96b697d7cb7938d525a2f31aaf161d0", "c3fcd3d76192e4007dfb496cca67e13b",
|
||||
"d174ab98d277d9f5a5611c2c9f419d9f", "57edf4a22be3c955ac49da2e2107b67a"];
|
||||
def tests = Hashtable(ZipLazy(examples, hashes));
|
||||
foreach (test in tests)
|
||||
Write($"$(IsValidMD5(test.Key, test.Value)) ");
|
||||
}
|
||||
}
|
||||
59
Task/MD5/NetRexx/md5.netrexx
Normal file
59
Task/MD5/NetRexx/md5.netrexx
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* NetRexx */
|
||||
|
||||
options replace format comments java crossref savelog symbols binary
|
||||
|
||||
import java.security.MessageDigest
|
||||
|
||||
MD5('The quick brown fox jumps over the lazy dog', '9e107d9d372bb6826bd81d3542a419d6')
|
||||
-- RFC 1321 MD5 test suite:
|
||||
MD5("", 'd41d8cd98f00b204e9800998ecf8427e')
|
||||
MD5("a", '0cc175b9c0f1b6a831c399e269772661')
|
||||
MD5("abc", '900150983cd24fb0d6963f7d28e17f72')
|
||||
MD5("message digest", 'f96b697d7cb7938d525a2f31aaf161d0')
|
||||
MD5("abcdefghijklmnopqrstuvwxyz", 'c3fcd3d76192e4007dfb496cca67e13b')
|
||||
MD5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 'd174ab98d277d9f5a5611c2c9f419d9f')
|
||||
MD5("12345678901234567890123456789012345678901234567890123456789012345678901234567890", '57edf4a22be3c955ac49da2e2107b67a')
|
||||
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method MD5(messageText, verifyCheck) public static
|
||||
|
||||
algorithm = 'MD5'
|
||||
digestSum = getDigest(messageText, algorithm)
|
||||
|
||||
say '<Message>'messageText'</Message>'
|
||||
say Rexx('<'algorithm'>').right(12) || digestSum'</'algorithm'>'
|
||||
say Rexx('<Verify>').right(12) || verifyCheck'</Verify>'
|
||||
if digestSum == verifyCheck then say algorithm 'Confirmed'
|
||||
else say algorithm 'Failed'
|
||||
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method getDigest(messageText = Rexx, algorithm = Rexx 'MD5', encoding = Rexx 'UTF-8', lowercase = boolean 1) public static returns Rexx
|
||||
|
||||
algorithm = algorithm.upper
|
||||
encoding = encoding.upper
|
||||
|
||||
message = String(messageText)
|
||||
messageBytes = byte[]
|
||||
digestBytes = byte[]
|
||||
digestSum = Rexx ''
|
||||
|
||||
do
|
||||
messageBytes = message.getBytes(encoding)
|
||||
md = MessageDigest.getInstance(algorithm)
|
||||
md.update(messageBytes)
|
||||
digestBytes = md.digest
|
||||
|
||||
loop b_ = 0 to digestBytes.length - 1
|
||||
bb = Rexx(digestBytes[b_]).d2x(2)
|
||||
if lowercase then digestSum = digestSum || bb.lower
|
||||
else digestSum = digestSum || bb.upper
|
||||
end b_
|
||||
catch ex = Exception
|
||||
ex.printStackTrace
|
||||
end
|
||||
|
||||
return digestSum
|
||||
2
Task/MD5/OCaml/md5.ocaml
Normal file
2
Task/MD5/OCaml/md5.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Digest.to_hex(Digest.string "The quick brown fox jumped over the lazy dog's back") ;;
|
||||
- : string = "e38ca1d920c4b8b8d3946b2c72f01680"
|
||||
7
Task/MD5/Objeck/md5.objeck
Normal file
7
Task/MD5/Objeck/md5.objeck
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class MD5 {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
in := "The quick brown fox jumped over the lazy dog's back"->ToByteArray();
|
||||
hash := Encryption.Hash->MD5(in);
|
||||
hash->ToHexString()->PrintLine();
|
||||
}
|
||||
}
|
||||
3
Task/MD5/Objective-C/md5-1.m
Normal file
3
Task/MD5/Objective-C/md5-1.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
NSString *myString = @"The quick brown fox jumped over the lazy dog's back";
|
||||
NSData *digest = [[myString dataUsingEncoding:NSUTF8StringEncoding] md5Digest]; // or another encoding of your choosing
|
||||
NSLog(@"%@", [digest hexadecimalRepresentation]);
|
||||
12
Task/MD5/Objective-C/md5-2.m
Normal file
12
Task/MD5/Objective-C/md5-2.m
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#import <CommonCrypto/CommonDigest.h>
|
||||
|
||||
NSString *myString = @"The quick brown fox jumped over the lazy dog's back";
|
||||
NSData *data = [myString dataUsingEncoding:NSUTF8StringEncoding]; // or another encoding of your choosing
|
||||
unsigned char digest[CC_MD5_DIGEST_LENGTH];
|
||||
if (CC_MD5([data bytes], [data length], digest)) {
|
||||
NSMutableString *hex = [NSMutableString string];
|
||||
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
|
||||
[hex appendFormat: @"%02x", (int)(digest[i])];
|
||||
}
|
||||
NSLog(@"%@", hex);
|
||||
}
|
||||
12
Task/MD5/Objective-C/md5-3.m
Normal file
12
Task/MD5/Objective-C/md5-3.m
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <openssl/md5.h>
|
||||
|
||||
NSString *myString = @"The quick brown fox jumped over the lazy dog's back";
|
||||
NSData *data = [myString dataUsingEncoding:NSUTF8StringEncoding]; // or another encoding of your choosing
|
||||
unsigned char digest[MD5_DIGEST_LENGTH];
|
||||
if (MD5([data bytes], [data length], digest)) {
|
||||
NSMutableString *hex = [NSMutableString string];
|
||||
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
|
||||
[hex appendFormat: @"%02x", (int)(digest[i])];
|
||||
}
|
||||
NSLog(@"%@", hex);
|
||||
}
|
||||
3
Task/MD5/Octave/md5.octave
Normal file
3
Task/MD5/Octave/md5.octave
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s = "The quick brown fox jumped over the lazy dog's back";
|
||||
hash = md5sum(s, true);
|
||||
disp(hash)
|
||||
9
Task/MD5/OpenEdge-Progress/md5.openedge
Normal file
9
Task/MD5/OpenEdge-Progress/md5.openedge
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MESSAGE
|
||||
1 STRING( HEX-ENCODE( MD5-DIGEST( "" ) ) ) SKIP
|
||||
2 STRING( HEX-ENCODE( MD5-DIGEST( "a" ) ) ) SKIP
|
||||
3 STRING( HEX-ENCODE( MD5-DIGEST( "abc" ) ) ) SKIP
|
||||
4 STRING( HEX-ENCODE( MD5-DIGEST( "message digest" ) ) ) SKIP
|
||||
5 STRING( HEX-ENCODE( MD5-DIGEST( "abcdefghijklmnopqrstuvwxyz" ) ) ) SKIP
|
||||
6 STRING( HEX-ENCODE( MD5-DIGEST( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ) ) ) SKIP
|
||||
7 STRING( HEX-ENCODE( MD5-DIGEST( "12345678901234567890123456789012345678901234567890123456789012345678901234567890" ) ) )
|
||||
VIEW-AS ALERT-BOX
|
||||
2
Task/MD5/Perl-6/md5.pl6
Normal file
2
Task/MD5/Perl-6/md5.pl6
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
use Digest::MD5;
|
||||
say Digest::MD5.md5_hex: "The quick brown fox jumped over the lazy dog's back";
|
||||
6
Task/MD5/Pike/md5.pike
Normal file
6
Task/MD5/Pike/md5.pike
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import String;
|
||||
import Crypto.MD5;
|
||||
|
||||
int main(){
|
||||
write( string2hex( hash( "The quick brown fox jumped over the lazy dog's back" ) ) + "\n" );
|
||||
}
|
||||
4
Task/MD5/PowerShell/md5.psh
Normal file
4
Task/MD5/PowerShell/md5.psh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$string = "The quick brown fox jumped over the lazy dog's back"
|
||||
$data = [Text.Encoding]::UTF8.GetBytes($string)
|
||||
$hash = [Security.Cryptography.MD5]::Create().ComputeHash($data)
|
||||
([BitConverter]::ToString($hash) -replace '-').ToLower()
|
||||
2
Task/MD5/PureBasic/md5.purebasic
Normal file
2
Task/MD5/PureBasic/md5.purebasic
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
test$ = "The quick brown fox jumped over the lazy dog's back"
|
||||
Debug MD5Fingerprint(@test$, StringByteLength(test$))
|
||||
2
Task/MD5/REBOL/md5.rebol
Normal file
2
Task/MD5/REBOL/md5.rebol
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
>> checksum/method "The quick brown fox jumped over the lazy dog" 'md5
|
||||
== #{08A008A01D498C404B0C30852B39D3B8}
|
||||
5
Task/MD5/RLaB/md5.rlab
Normal file
5
Task/MD5/RLaB/md5.rlab
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
>> x = "The quick brown fox jumped over the lazy dog's back"
|
||||
The quick brown fox jumped over the lazy dog's back
|
||||
|
||||
>> hash("md5", x)
|
||||
e38ca1d920c4b8b8d3946b2c72f01680
|
||||
1
Task/MD5/SQL/md5.sql
Normal file
1
Task/MD5/SQL/md5.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
SELECT MD5('The quick brown fox jumped over the lazy dog\'s back')
|
||||
1
Task/MD5/Slate/md5.slate
Normal file
1
Task/MD5/Slate/md5.slate
Normal file
|
|
@ -0,0 +1 @@
|
|||
'The quick brown fox jumped over the lazy dog\'s back' md5String. "==> 'e38ca1d920c4b8b8d3946b2c72f01680'"
|
||||
1
Task/MD5/Suneido/md5.suneido
Normal file
1
Task/MD5/Suneido/md5.suneido
Normal file
|
|
@ -0,0 +1 @@
|
|||
Md5('The quick brown fox jumped over the lazy dog\'s back')
|
||||
1
Task/MD5/UNIX-Shell/md5-1.sh
Normal file
1
Task/MD5/UNIX-Shell/md5-1.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo -n "The quick brown fox jumped over the lazy dog's back" | md5sum
|
||||
1
Task/MD5/UNIX-Shell/md5-2.sh
Normal file
1
Task/MD5/UNIX-Shell/md5-2.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
echo -n "The quick brown fox jumped over the lazy dog's back" | md5
|
||||
2
Task/MD5/UNIX-Shell/md5-3.sh
Normal file
2
Task/MD5/UNIX-Shell/md5-3.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
echo -n "The quick brown fox jumped over the lazy dog's back" |
|
||||
openssl md5 | sed 's/.*= //'
|
||||
Loading…
Add table
Add a link
Reference in a new issue