@speckle/objectsender 2.25.0 → 2.25.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils/Sha1.ts DELETED
@@ -1,138 +0,0 @@
1
- /* eslint-disable camelcase */
2
- /**
3
- * Basic hashing function, to avoid dependencies and crazy build processes
4
- * @param msg
5
- * @returns
6
- */
7
- export function SHA1(msg: string) {
8
- function rotate_left(n: number, s: number) {
9
- const t4 = (n << s) | (n >>> (32 - s))
10
- return t4
11
- }
12
- function cvt_hex(val: number) {
13
- let str = ''
14
- let i
15
- let v
16
- for (i = 7; i >= 0; i--) {
17
- v = (val >>> (i * 4)) & 0x0f
18
- str += v.toString(16)
19
- }
20
- return str
21
- }
22
- function Utf8Encode(string: string) {
23
- string = string.replace(/\r\n/g, '\n')
24
- let utftext = ''
25
- for (let n = 0; n < string.length; n++) {
26
- const c = string.charCodeAt(n)
27
- if (c < 128) {
28
- utftext += String.fromCharCode(c)
29
- } else if (c > 127 && c < 2048) {
30
- utftext += String.fromCharCode((c >> 6) | 192)
31
- utftext += String.fromCharCode((c & 63) | 128)
32
- } else {
33
- utftext += String.fromCharCode((c >> 12) | 224)
34
- utftext += String.fromCharCode(((c >> 6) & 63) | 128)
35
- utftext += String.fromCharCode((c & 63) | 128)
36
- }
37
- }
38
- return utftext
39
- }
40
- let blockstart
41
- let i, j
42
- const W = new Array(80)
43
- let H0 = 0x67452301
44
- let H1 = 0xefcdab89
45
- let H2 = 0x98badcfe
46
- let H3 = 0x10325476
47
- let H4 = 0xc3d2e1f0
48
- let A, B, C, D, E
49
- let temp
50
- msg = Utf8Encode(msg)
51
- const msg_len = msg.length
52
- const word_array = [] as unknown[]
53
- for (i = 0; i < msg_len - 3; i += 4) {
54
- j =
55
- (msg.charCodeAt(i) << 24) |
56
- (msg.charCodeAt(i + 1) << 16) |
57
- (msg.charCodeAt(i + 2) << 8) |
58
- msg.charCodeAt(i + 3)
59
- word_array.push(j)
60
- }
61
- switch (msg_len % 4) {
62
- case 0:
63
- i = 0x080000000
64
- break
65
- case 1:
66
- i = (msg.charCodeAt(msg_len - 1) << 24) | 0x0800000
67
- break
68
- case 2:
69
- i =
70
- (msg.charCodeAt(msg_len - 2) << 24) |
71
- (msg.charCodeAt(msg_len - 1) << 16) |
72
- 0x08000
73
- break
74
- case 3:
75
- i =
76
- (msg.charCodeAt(msg_len - 3) << 24) |
77
- (msg.charCodeAt(msg_len - 2) << 16) |
78
- (msg.charCodeAt(msg_len - 1) << 8) |
79
- 0x80
80
- break
81
- }
82
- word_array.push(i)
83
- while (word_array.length % 16 !== 14) word_array.push(0)
84
- word_array.push(msg_len >>> 29)
85
- word_array.push((msg_len << 3) & 0x0ffffffff)
86
- for (blockstart = 0; blockstart < word_array.length; blockstart += 16) {
87
- for (i = 0; i < 16; i++) W[i] = word_array[blockstart + i]
88
- for (i = 16; i <= 79; i++)
89
- W[i] = rotate_left(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1)
90
- A = H0
91
- B = H1
92
- C = H2
93
- D = H3
94
- E = H4
95
- for (i = 0; i <= 19; i++) {
96
- temp =
97
- (rotate_left(A, 5) + ((B & C) | (~B & D)) + E + W[i] + 0x5a827999) & 0x0ffffffff
98
- E = D
99
- D = C
100
- C = rotate_left(B, 30)
101
- B = A
102
- A = temp
103
- }
104
- for (i = 20; i <= 39; i++) {
105
- temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ed9eba1) & 0x0ffffffff
106
- E = D
107
- D = C
108
- C = rotate_left(B, 30)
109
- B = A
110
- A = temp
111
- }
112
- for (i = 40; i <= 59; i++) {
113
- temp =
114
- (rotate_left(A, 5) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8f1bbcdc) &
115
- 0x0ffffffff
116
- E = D
117
- D = C
118
- C = rotate_left(B, 30)
119
- B = A
120
- A = temp
121
- }
122
- for (i = 60; i <= 79; i++) {
123
- temp = (rotate_left(A, 5) + (B ^ C ^ D) + E + W[i] + 0xca62c1d6) & 0x0ffffffff
124
- E = D
125
- D = C
126
- C = rotate_left(B, 30)
127
- B = A
128
- A = temp
129
- }
130
- H0 = (H0 + A) & 0x0ffffffff
131
- H1 = (H1 + B) & 0x0ffffffff
132
- H2 = (H2 + C) & 0x0ffffffff
133
- H3 = (H3 + D) & 0x0ffffffff
134
- H4 = (H4 + E) & 0x0ffffffff
135
- }
136
- const h = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4)
137
- return h.toLowerCase().substring(0, 40)
138
- }