Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/MD5/PARI-GP/md5-1.parigp
Normal file
27
Task/MD5/PARI-GP/md5-1.parigp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <pari/pari.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#define HEX(x) (((x) < 10)? (x)+'0': (x)-10+'a')
|
||||
|
||||
/*
|
||||
* PARI/GP func: MD5 hash
|
||||
*
|
||||
* gp code: install("plug_md5", "s", "MD5", "<library path>");
|
||||
*/
|
||||
GEN plug_md5(char *text)
|
||||
{
|
||||
char md[MD5_DIGEST_LENGTH];
|
||||
char hash[sizeof(md) * 2 + 1];
|
||||
int i;
|
||||
|
||||
MD5((unsigned char*)text, strlen(text), (unsigned char*)md);
|
||||
|
||||
for (i = 0; i < sizeof(md); i++) {
|
||||
hash[i+i] = HEX((md[i] >> 4) & 0x0f);
|
||||
hash[i+i+1] = HEX(md[i] & 0x0f);
|
||||
}
|
||||
|
||||
hash[sizeof(md) * 2] = 0;
|
||||
|
||||
return strtoGENstr(hash);
|
||||
}
|
||||
3
Task/MD5/PARI-GP/md5-2.parigp
Normal file
3
Task/MD5/PARI-GP/md5-2.parigp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
install("plug_md5", "s", "MD5", "~/libmd5.so");
|
||||
|
||||
MD5("The quick brown fox jumped over the lazy dog's back")
|
||||
23
Task/MD5/PARI-GP/md5-3.parigp
Normal file
23
Task/MD5/PARI-GP/md5-3.parigp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
md5( message ) = { my(
|
||||
a = 0x67452301, b = 0xefcdab89, c = 0x98badcfe, d = 0x10325476,
|
||||
s = [ 7, 12, 17, 22; 5, 9, 14, 20; 4, 11, 16, 23; 6, 10, 15, 21 ],
|
||||
msg = concat( Vec( concat(Vecsmall(message), Vecsmall(128)), (#message + 9) \ 64 * 64 + 56 ),
|
||||
Vecrev(digits( #message % 2^61 * 8, 256), 8)), \\ little endian !
|
||||
leftrotate(x, c) = x << c + x >> (32-c)
|
||||
);
|
||||
\\*** Process the message in successive 512-bit chunks ***
|
||||
forstep( m=1, #msg, 512/8,
|
||||
my( \\ break chunk into 32-bit words M[j] - LITTLE ENDIAN !
|
||||
M = vector( 16, j, fromdigits( Vecrev(msg[ m + j*4 - 4 .. m + j*4 - 1 ]), 2^8 )),
|
||||
A = a, B = b, C = c, D = d);
|
||||
for( i = 0 , 63 , [A, D, C, B] = [D, C, B, B + leftrotate( ( A + abs(sin(i+1))\2^-32 +
|
||||
if( i < 16 , bitor( bitand(B , C) , bitand( bitneg(B) , D)) + M[ i +1]
|
||||
, i < 32 , bitor( bitand(D , B) , bitand( bitneg(D) , C)) + M[ (5*i + 1) % 16 +1]
|
||||
, i < 48 , bitxor( bitxor( B , C ) , D ) + M[ (3*i + 5) % 16 +1]
|
||||
, bitxor( C , bitor( bitneg(D), B)) + M[ 7*i % 16 +1]
|
||||
)) % 2^32, s[i\16+1, i%4+1] )]
|
||||
); \\ end for
|
||||
[a,b,c,d] = ([a,b,c,d] + [A,B,C,D]) % 2^32 ;
|
||||
); \\ end forstep
|
||||
Strprintf("%032x",fromdigits(Vecrev(digits(fromdigits([d,c,b,a],2^32),256),16),256))
|
||||
}
|
||||
1
Task/MD5/PARI-GP/md5-4.parigp
Normal file
1
Task/MD5/PARI-GP/md5-4.parigp
Normal file
|
|
@ -0,0 +1 @@
|
|||
gp > md5("")
|
||||
1
Task/MD5/PARI-GP/md5-5.parigp
Normal file
1
Task/MD5/PARI-GP/md5-5.parigp
Normal file
|
|
@ -0,0 +1 @@
|
|||
gp > md5("The quick brown fox jumps over lazy dogs.")
|
||||
11
Task/MD5/PARI-GP/md5-6.parigp
Normal file
11
Task/MD5/PARI-GP/md5-6.parigp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
program GetMd5;
|
||||
|
||||
uses md5;
|
||||
|
||||
var
|
||||
strEncrypted : string;
|
||||
|
||||
begin
|
||||
strEncrypted := md5Print(md5String('The quick brown fox jumped over the lazy dog''s back'));
|
||||
writeln(strEncrypted);
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue