Skip to content

Commit f70b03a

Browse files
authored
Merge pull request #262 from hyperoslo/updated-md5
Updated MD5
2 parents 042b2cd + aace3c7 commit f70b03a

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

Source/Shared/Library/MD5.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// swiftlint:disable comma function_parameter_count variable_name syntactic_sugar function_body_length vertical_whitespace
2-
3-
// https://github.com/onmyway133/SwiftHash/blob/master/Sources/MD5.swift
4-
51
/*
62
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
73
* Digest Algorithm, as defined in RFC 1321.
@@ -103,13 +99,10 @@ func rstr_md5(_ input: [CUnsignedChar]) -> [CUnsignedChar] {
10399
}
104100

105101
/*
106-
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
107-
* to work around bugs in some JS interpreters.
102+
* Add integers, wrapping at 2^32.
108103
*/
109104
func safe_add(_ x: Int32, _ y: Int32) -> Int32 {
110-
let lsw = (x & 0xFFFF) + (y & 0xFFFF)
111-
let msw = (x >> 16) + (y >> 16) + (lsw >> 16)
112-
return (msw << 16) | (lsw & 0xFFFF)
105+
return x &+ y
113106
}
114107

115108
/*

0 commit comments

Comments
 (0)