Disco Octopus wrote:[color=blue]
> Hi,
>
> Does anyone know of a MD5 script written in javascript?
>
> Thanks
>
>
>[/color]
A quick Google search yeilds several.
Here is one:
I provide free JavaScript implementations of these secure hash algorithms. Their most common applications is for improving security on web login forms.
Jerry Park wrote:[color=blue]
> Disco Octopus wrote:[color=green]
>> Hi,
>>
>> Does anyone know of a MD5 script written in javascript?
>>
>> Thanks
>>
>>
>>[/color]
> A quick Google search yeilds several.
> Here is one:
> http://pajhome.org.uk/crypt/md5/[/color]
Yes. you are correct. Thanks.
What I am *really* after is some code (of any language) that will show me
how to generate an MD5 output/fingerprint that is _easy_ to follow, and to
rewrite in other languages. The language that I would like to write it for
is in UNIFACE. Now I know that there is no UNIFACE code that exists to
generate MD5 output. I can follow most languages, but some bits of some
languages are not quite UNIFACE *friendly*. For example there is no easy
way to translate the following into a UNIFACE piece of code....
If I recall well, mail.yahoo.com uses Javascript/MD5 when you login using
non-secure mode.
--
Elias
"Disco Octopus" <discooctopusN0 5PAM@yahoo.com> wrote in message
news:RN_Rb.349$ KW.19163@news.o ptus.net.au...[color=blue]
> Hi,
>
> Does anyone know of a MD5 script written in javascript?
>
> Thanks
>
>
>[/color]
Here is one using vbscript,.
Called like this sRetVal = SHADIGEST(sMess age)
<SCRIPT LANGUAGE="VBScr ipt">
<%
' DON NOT EDIT THIS FILE, USER ACCESS WILL BE NON FUNCTIONAL
'AUSTRALIAN SCIENTIFIC SOFTWARE
'PHONE (03) 776 0728 Mobile: 0412 548 333 Email dgrover@assoft. com.au
' This MD5 algorithm is one of the industry standard methods for generating
digital
' signatures.
'
'**Start Encode**
Private Function LShift(lValue, iShiftBits)
If iShiftBits = 0 Then
LShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And 1 Then
LShift = &H80000000
Else
LShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 Or iShiftBits > 31 Then
Err.Raise 6
End If
If (lValue And m_l2Power(31 - iShiftBits)) Then
LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) *
m_l2Power(iShif tBits)) Or &H80000000
Else
LShift = ((lValue And m_lOnBits(31 - iShiftBits)) *
m_l2Power(iShif tBits))
End If
End Function
Private Function RShift(lValue, iShiftBits)
If iShiftBits = 0 Then
RShift = lValue
Exit Function
ElseIf iShiftBits = 31 Then
If lValue And &H80000000 Then
RShift = 1
Else
RShift = 0
End If
Exit Function
ElseIf iShiftBits < 0 Or iShiftBits > 31 Then
Err.Raise 6
End If
RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShif tBits)
If (lValue And &H80000000) Then
RShift = (RShift Or (&H40000000 \ m_l2Power(iShif tBits - 1)))
End If
End Function
Private Function AddUnsigned(lX, lY)
Dim lX4
Dim lY4
Dim lX8
Dim lY8
Dim lResult
lX8 = lX And &H80000000
lY8 = lY And &H80000000
lX4 = lX And &H40000000
lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 Then
lResult = lResult Xor &H80000000 Xor lX8 Xor lY8
ElseIf lX4 Or lY4 Then
If lResult And &H40000000 Then
lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8
Else
lResult = lResult Xor &H40000000 Xor lX8 Xor lY8
End If
Else
lResult = lResult Xor lX8 Xor lY8
End If
AddUnsigned = lResult
End Function
Private Function Ch(x, y, z)
Ch = ((x And y) Xor ((Not x) And z))
End Function
Private Function Maj(x, y, z)
Maj = ((x And y) Xor (x And z) Xor (y And z))
End Function
Private Function S(x, n)
S = (RShift(x, (n And m_lOnBits(4))) Or LShift(x, (32 - (n And
m_lOnBits(4)))) )
End Function
Private Function R(x, n)
R = RShift(x, CInt(n And m_lOnBits(4)))
End Function
Private Function Sigma0(x)
Sigma0 = (S(x, 2) Xor S(x, 13) Xor S(x, 22))
End Function
Private Function Sigma1(x)
Sigma1 = (S(x, 6) Xor S(x, 11) Xor S(x, 25))
End Function
Private Function Gamma0(x)
Gamma0 = (S(x, 7) Xor S(x, 18) Xor R(x, 3))
End Function
Private Function Gamma1(x)
Gamma1 = (S(x, 17) Xor S(x, 19) Xor R(x, 10))
End Function
Private Function ConvertToWordAr ray(sMessage)
Dim lMessageLength
Dim lNumberOfWords
Dim lWordArray()
Dim lBytePosition
Dim lByteCount
Dim lWordCount
Dim lByte
"Disco Octopus" <discooctopusN0 5PAM@yahoo.com> wrote in message
news:RN_Rb.349$ KW.19163@news.o ptus.net.au...[color=blue]
> Hi,
>
> Does anyone know of a MD5 script written in javascript?
>
> Thanks
>
>
>[/color]
: I can follow most languages, but some bits of some
: languages are not quite UNIFACE *friendly*. For example there is no easy
: way to translate the following into a UNIFACE piece of code....
:
: x[len >> 5] |= 0x80 << ((len) % 32);
: x[(((len + 64) >>> 9) << 4) + 14] = len;
Maybe you can tell us what mathematical fuctions UNIFACE has:
Power
Shift
Div
Mod
length_of_input
Else you might need a mathematian to help you,
Wouter
DJ WIce wrote:[color=blue][color=green]
>> I can follow most languages, but some bits of some
>> languages are not quite UNIFACE *friendly*. For example there is no
>> easy way to translate the following into a UNIFACE piece of code....
>>
>> x[len >> 5] |= 0x80 << ((len) % 32);
>> x[(((len + 64) >>> 9) << 4) + 14] = len;[/color]
>
> Maybe you can tell us what mathematical fuctions UNIFACE has:
>
> Power
> Shift
> Div
> Mod
> length_of_input[/color]
here is what is available in UNIFACE proc language regarding mathematical
usage....
abs - Return the absolute value of X (|X|).
acos - Return the arc cosine of X.
asin - Return the arc sine of X.
atan - Return the arc tangent of X.
cos - Return the cosine of X.
e - Return the value of e.
$exp Return the exponential of X (eX).
$exp10 Return the base 10 exponential of X (10X).
fact - Calculate the factorial of X (X!).
frac - Return the fractional part of X.
int - Return the integer part of X.
log - Return the natural logarithm of X (logeX).
log10 - Return the base 10 logarithm of X (log10X).
pi - Return the value of pi.
power Calculate the value of X raised to the power of Y (XY).
sin - Return the sine of X.
sqrt - Calculate the square root of X.
tan - Return the tangent of X.
length - return character length of item
^ - modulus
+ - plus
- - minus
* - multiply
/ - divide
<, <=, !=, =, ==, >=, >
& - logical and
| - logical or
!- logical not
there is also something (cant think of it right now) that returns the
numeric ascii value of a character.
: here is what is available in UNIFACE proc language regarding mathematical
: usage....
:
: <snip>
Is there some code to convert between the hexadecimal and decimal system?
&h or # or something.
Does power calculate the power of X to negative values of Y?
"Disco Octopus" <discooctopusN0 5PAM@yahoo.com> wrote in message
news:xbiSb.366$ KW.20897@news.o ptus.net.au...
<snip>[color=blue][color=green][color=darkred]
>>> x[len >> 5] |= 0x80 << ((len) % 32);
>>> x[(((len + 64) >>> 9) << 4) + 14] = len;[/color]
>>
>>Maybe you can tell us what mathematical fuctions
>>UNIFACE has:[/color][/color]
<snip>[color=blue]
>here is what is available in UNIFACE proc language
>regarding mathematical usage....
>
>
> abs - Return the absolute value of X (|X|).
> acos - Return the arc cosine of X.[/color]
<snip>[color=blue]
> & - logical and
> | - logical or
> !- logical not[/color]
<snip>
But does UNIFACE have bitwise operators as MD5 makes extensive use of
those. And what number types are available (double precision floats, 32
and 64 bit integers)?
Many of the bitwiser operators in JavaScript could be substituted with
mathematical operations:-
var x = y >> 1;
- and -
var x = Math.floor(y / 2);
-would be equivalent so long as y was representable as a positive 32 bit
signed integer . Shifting in the other direction might be a bit more
problematic.
But MD5 uses bitwise OR and XOR extensively and they will be a pain to
implement if not natively supported.
in news:bvdig6$1ln $1$8302bc10@new s.demon.co.uk,
Richard Cornford typed:[color=blue]
> "Disco Octopus" <discooctopusN0 5PAM@yahoo.com> wrote in message
> news:xbiSb.366$ KW.20897@news.o ptus.net.au...
> <snip>[color=green][color=darkred]
>>>> x[len >> 5] |= 0x80 << ((len) % 32);
>>>> x[(((len + 64) >>> 9) << 4) + 14] = len;
>>>
>>> Maybe you can tell us what mathematical fuctions
>>> UNIFACE has:[/color][/color]
> <snip>[color=green]
>> here is what is available in UNIFACE proc language
>> regarding mathematical usage....
>>
>>
>> abs - Return the absolute value of X (|X|).
>> acos - Return the arc cosine of X.[/color]
> <snip>[color=green]
>> & - logical and[color=darkred]
>>> - logical or[/color]
>> !- logical not[/color]
> <snip>
>
> But does UNIFACE have bitwise operators as MD5 makes extensive use of
> those. And what number types are available (double precision floats,
> 32 and 64 bit integers)?[/color]
No. UNIFACE does not have this ability. No bitwise operators.
[color=blue]
>
> Many of the bitwiser operators in JavaScript could be substituted with
> mathematical operations:-
>
> var x = y >> 1;
>
> - and -
>
> var x = Math.floor(y / 2);
>
> -would be equivalent so long as y was representable as a positive 32
> bit signed integer . Shifting in the other direction might be a bit
> more problematic.
>
> But MD5 uses bitwise OR and XOR extensively and they will be a pain to
> implement if not natively supported.
>
> Richard.[/color]
I think that the only thing that UNIFACE can not handle for this, is bit
manipulation. I think this will be the falling over for this thought
process.
"Disco Octopus" <discooctopus@y ahoo.com> wrote in message
news:uzsSb.221$ %W.7509@nnrp1.o zemail.com.au.. .
<snip>[color=blue][color=green]
>>But does UNIFACE have bitwise operators as MD5 makes
>>extensive use of those. And what number types are
>>available (double precision floats, 32 and 64 bit
>>integers)?[/color]
>
>No. UNIFACE does not have this ability. No bitwise
>operators.[/color]
<snip>[color=blue]
>I think that the only thing that UNIFACE can not handle
>for this, is bit manipulation. I think this will be the
>falling over for this thought process.[/color]
You didn't mention what number types it does have. But that probably
doesn't matter as UNIFACE doesn't sound suited to the task. You probably
still could re-represent the numbers as 32 element arrays of boolean
values and re-produce the bitwiser operations as functions that looped
through those arrays doing the equivalent logical operations on the
corresponding pairs of boolean values and then use a resulting arrays to
re-construct numeric results. But the prospect of doing that and then
executing it on a CPU that you know could do those same operations
directly in a couple of clock cycles does not appeal.
Comment