How to resolve the algorithm RIPEMD-160 step by step in the PARI/GP programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm RIPEMD-160 step by step in the PARI/GP programming language
Table of Contents
Problem Statement
RIPEMD-160 is another hash function; it computes a 160-bit message digest. There is a RIPEMD-160 home page, with test vectors and pseudocode for RIPEMD-160. For padding the message, RIPEMD-160 acts like MD4 (RFC 1320). Find the RIPEMD-160 message digest of a string of octets. Use the ASCII encoded string “Rosetta Code”. You may either call an RIPEMD-160 library, or implement RIPEMD-160 in your language.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm RIPEMD-160 step by step in the PARI/GP programming language
Source code in the pari/gp programming language
#include
#include
#define HEX(x) (((x) < 10)? (x)+'0': (x)-10+'a')
GEN plug_ripemd160(char *text)
{
char md[RIPEMD160_DIGEST_LENGTH];
char hash[sizeof(md) * 2 + 1];
int i;
RIPEMD160((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);
}
install("plug_ripemd160", "s", "RIPEMD160", "~/libripemd160.so");
RIPEMD160("Rosetta Code")
install(RIPEMD160,"vsLs",,"/usr/lib/x86_64-linux-gnu/libcrypto.so")
ripemd160(a)=
{
my(b=Strchr(vectorsmall(20,i,32)));
RIPEMD160(a,length(a),b);
Strprintf("%x",fromdigits(Vec(Vecsmall(b)),256));
}
ripemd160("Rosetta Code")
You may also check:How to resolve the algorithm Quine step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Minimal steps down to 1 step by step in the zkl programming language
You may also check:How to resolve the algorithm Levenshtein distance step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm 100 doors step by step in the Miranda programming language
You may also check:How to resolve the algorithm Koch curve step by step in the Java programming language