2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
27
Task/MD5/PARI-GP/md5-1.pari
Normal file
27
Task/MD5/PARI-GP/md5-1.pari
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.pari
Normal file
3
Task/MD5/PARI-GP/md5-2.pari
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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue