VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsHabboRC4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Dim di(15) As String 'Hex

Dim table(255) As Long
Dim Key(255) As Long
Dim keyWindow(1023) As Long
Dim i As Long
Dim j As Long

Public Sub setKey(s As String)
On Error Resume Next

Dim s1 As String
Dim s2 As String
Dim i As Long
Dim i2 As Long
Dim l As Long
Dim j As Long
Dim j2 As String
    'INITIALIZE PRIVATE KEY
    Call Initialize

    'DECODE KEY
    If Len(s) Mod 2 = 1 Then
        s = Left(s, Len(s) - 1)
    End If
    
    s1 = Mid(s, 1, Len(s) / 2)
    s2 = Mid(s, Len(s) / 2 + 1, Len(s) / 2)
    l = 0
    For i = 1 To Len(s1)
        j2 = Mid(s2, i, 1)
        i2 = 1
        Do Until Mid(s1, i2, 1) = j2
            If i2 > Len(s1) Then
                i2 = -1
                Exit Do
            End If
            i2 = i2 + 1
        Loop
        j = i2 - 1
        
        If j Mod 2 = 0 Then
            j = j * 2
        End If
        If (i - 1) Mod 3 = 0 Then
            j = j * 3
        End If
        If j < 0 Then
            j = Len(s1) Mod 2
        End If
        l = l + j
        l = l Xor LShift(j, ((i - 1) Mod 3) * 8)
    Next
    
    i = 0
    j = 0

    'INITIALIZE PUBLIC KEY
    Call Init(l)
    
    i = 0
    j = 0
    Call preMixTable("eb11nmhdwbn733c2xjv1qln3ukpe0hvce0ylr02s12sv96rus2ohexr9cp8rufbmb1mdb732j1l3kehc0l0s2v6u2hx9prfmu", 17)
End Sub

Public Function encipher(ByVal Data As String) As String
On Error Resume Next

Dim cipher As String
Dim t As Long
Dim k As Long
Dim a As Long
Dim c As Long
    t = 0
    k = 0
    For a = 1 To Len(Data)
    
        i = (i + 1) Mod 256
        j = (j + table(i)) Mod 256
        t = table(i)
        table(i) = table(j)
        table(j) = t
        k = table((table(i) + table(j)) Mod 256)
        
        c = Asc(Mid(Data, a, 1)) Xor k
        
        If c <= 0 Then
            cipher = cipher & "00"
        Else
            cipher = cipher & di(RShift(c, 4) And &HF)
            cipher = cipher & di(c And &HF)
        End If
    Next
    
    encipher = cipher
End Function

Public Function decipher(ByVal Data As String) As String
On Error Resume Next

Dim cipher As String
Dim t As Long
Dim k As Long
Dim a As Long
    t = 0
    k = 0
    a = 1
    Do
        i = (i + 1) Mod 256
        j = (j + table(i)) Mod 256
        t = table(i)
        table(i) = table(j)
        table(j) = t
        k = table((table(i) + table(j)) Mod 256)
        
        t = HexToDec(Mid(Data, a, a + 2))
        cipher = cipher & Chr(t Xor k)
        a = a + 2
    Loop Until a >= Len(Data)
    
    decipher = cipher
End Function

Private Function HexToDec(ByVal Data As String) As Long
On Error Resume Next

Dim tempData As String
Dim y As Long
Dim tStr As String
Dim tHex As String
    tempData = Data
    For y = (1) To Len(Data) Step 2
        tStr = Mid(Data, y, 2)
        tHex = tHex & Chr("&h" & tStr)
    Next y

    HexToDec = Asc(tHex)
End Function

Private Function Init(ByVal sKey As String) As Boolean
On Error Resume Next

Dim keyValue As Long
Dim keyLength As Long
Dim keyOffset As Long
Dim keySkip As Long
Dim prevKey As Long
Dim w() As Long
Dim b As Long
Dim a As Long
Dim t As Long
Dim m As Long
Dim tOwn, tGiven As Long

    keyValue = Int(sKey)
    keyLength = (keyValue And 248) / 8
    
    If keyLength < 20 Then
        keyLength = keyLength + 20
    End If
    keyOffset = keyValue Mod 1024
    
    prevKey = 0
    m = 5
    
    ReDim w(keyLength - 1)
    tGiven = keyValue
    
    For i = 0 To keyLength - 1
        tOwn = keyWindow(Math.Abs(keyOffset + i) Mod (1024))
        w(i) = Math.Abs(tGiven Xor tOwn)
        If i = 31 Then
            tGiven = keyValue
        Else
            tGiven = Int(tGiven / 2)
        End If
    Next
    
    For a = 0 To 255
        Key(a) = w(a Mod (UBound(w) + 1))
        table(a) = a
    Next

    b = 0
    t = 0
    For a = 0 To 255
        b = (b + table(a) + Key(a)) Mod 256
        t = table(a)
        table(a) = table(b)
        table(b) = t
    Next
    
    i = 0
    Init = True
End Function

Private Sub preMixTable(Data As String, Count As Long)
On Error Resume Next

Dim i As Long
Dim TEMP As String
  
  For i = 1 To Count
    TEMP = encipher(Data)
  Next
End Sub

Private Sub Initialize()
On Error Resume Next

    For i = 0 To 15
        Select Case i
        Case 10
            di(i) = "A"
        Case 11
            di(i) = "B"
        Case 12
            di(i) = "C"
        Case 13
            di(i) = "D"
        Case 14
            di(i) = "E"
        Case 15
            di(i) = "F"
        Case Else
            di(i) = i
        End Select
    Next
    keyWindow(0) = 204
keyWindow(1) = 53
keyWindow(2) = 74
keyWindow(3) = 109
keyWindow(4) = 63
keyWindow(5) = 4
keyWindow(6) = 163
keyWindow(7) = 182
keyWindow(8) = 210
keyWindow(9) = 186
keyWindow(10) = 19
keyWindow(11) = 162
keyWindow(12) = 160
keyWindow(13) = 115
keyWindow(14) = 139
keyWindow(15) = 83
keyWindow(16) = 235
keyWindow(17) = 177
keyWindow(18) = 14
keyWindow(19) = 15
keyWindow(20) = 11
keyWindow(21) = 127
keyWindow(22) = 4
keyWindow(23) = 210
keyWindow(24) = 222
keyWindow(25) = 138
keyWindow(26) = 10
keyWindow(27) = 138
keyWindow(28) = 151
keyWindow(29) = 236
keyWindow(30) = 158
keyWindow(31) = 186
keyWindow(32) = 67
keyWindow(33) = 1
keyWindow(34) = 168
keyWindow(35) = 69
keyWindow(36) = 139
keyWindow(37) = 214
keyWindow(38) = 243
keyWindow(39) = 32
keyWindow(40) = 157
keyWindow(41) = 161
keyWindow(42) = 211
keyWindow(43) = 155
keyWindow(44) = 20
keyWindow(45) = 192
keyWindow(46) = 214
keyWindow(47) = 155
keyWindow(48) = 12
keyWindow(49) = 153
keyWindow(50) = 192
keyWindow(51) = 112
keyWindow(52) = 98
keyWindow(53) = 146
keyWindow(54) = 33
keyWindow(55) = 30
keyWindow(56) = 22
keyWindow(57) = 131
keyWindow(58) = 81
keyWindow(59) = 161
keyWindow(60) = 105
keyWindow(61) = 142
keyWindow(62) = 103
keyWindow(63) = 204
keyWindow(64) = 112
keyWindow(65) = 9
keyWindow(66) = 167
keyWindow(67) = 185
keyWindow(68) = 176
keyWindow(69) = 51
keyWindow(70) = 27
keyWindow(71) = 166
keyWindow(72) = 249
keyWindow(73) = 228
keyWindow(74) = 24
keyWindow(75) = 165
keyWindow(76) = 197
keyWindow(77) = 25
keyWindow(78) = 166
keyWindow(79) = 216
keyWindow(80) = 74
keyWindow(81) = 14
keyWindow(82) = 104
keyWindow(83) = 15
keyWindow(84) = 77
keyWindow(85) = 49
keyWindow(86) = 6
keyWindow(87) = 50
keyWindow(88) = 65
keyWindow(89) = 126
keyWindow(90) = 10
keyWindow(91) = 187
keyWindow(92) = 15
keyWindow(93) = 17
keyWindow(94) = 189
keyWindow(95) = 155
keyWindow(96) = 246
keyWindow(97) = 221
keyWindow(98) = 92
keyWindow(99) = 104
keyWindow(100) = 79
keyWindow(101) = 87
keyWindow(102) = 186
keyWindow(103) = 88
keyWindow(104) = 80
keyWindow(105) = 50
keyWindow(106) = 223
keyWindow(107) = 126
keyWindow(108) = 148
keyWindow(109) = 217
keyWindow(110) = 81
keyWindow(111) = 223
keyWindow(112) = 91
keyWindow(113) = 70
keyWindow(114) = 165
keyWindow(115) = 237
keyWindow(116) = 150
keyWindow(117) = 95
keyWindow(118) = 195
keyWindow(119) = 205
keyWindow(120) = 199
keyWindow(121) = 176
keyWindow(122) = 156
keyWindow(123) = 122
keyWindow(124) = 187
keyWindow(125) = 232
keyWindow(126) = 252
keyWindow(127) = 230
keyWindow(128) = 169
keyWindow(129) = 94
keyWindow(130) = 157
keyWindow(131) = 194
keyWindow(132) = 44
keyWindow(133) = 164
keyWindow(134) = 208
keyWindow(135) = 22
keyWindow(136) = 141
keyWindow(137) = 139
keyWindow(138) = 167
keyWindow(139) = 236
keyWindow(140) = 201
keyWindow(141) = 42
keyWindow(142) = 130
keyWindow(143) = 14
keyWindow(144) = 44
keyWindow(145) = 57
keyWindow(146) = 253
keyWindow(147) = 224
keyWindow(148) = 130
keyWindow(149) = 118
keyWindow(150) = 242
keyWindow(151) = 226
keyWindow(152) = 146
keyWindow(153) = 202
keyWindow(154) = 154
keyWindow(155) = 40
keyWindow(156) = 201
keyWindow(157) = 171
keyWindow(158) = 160
keyWindow(159) = 91
keyWindow(160) = 143
keyWindow(161) = 144
keyWindow(162) = 150
keyWindow(163) = 197
keyWindow(164) = 169
keyWindow(165) = 204
keyWindow(166) = 121
keyWindow(167) = 131
keyWindow(168) = 139
keyWindow(169) = 112
keyWindow(170) = 214
keyWindow(171) = 196
keyWindow(172) = 74
keyWindow(173) = 123
keyWindow(174) = 159
keyWindow(175) = 220
keyWindow(176) = 77
keyWindow(177) = 176
keyWindow(178) = 151
keyWindow(179) = 73
keyWindow(180) = 125
keyWindow(181) = 135
keyWindow(182) = 166
keyWindow(183) = 26
keyWindow(184) = 176
keyWindow(185) = 31
keyWindow(186) = 255
keyWindow(187) = 234
keyWindow(188) = 91
keyWindow(189) = 30
keyWindow(190) = 218
keyWindow(191) = 41
keyWindow(192) = 121
keyWindow(193) = 17
keyWindow(194) = 45
keyWindow(195) = 3
keyWindow(196) = 234
keyWindow(197) = 35
keyWindow(198) = 185
keyWindow(199) = 52
keyWindow(200) = 112
keyWindow(201) = 108
keyWindow(202) = 65
keyWindow(203) = 72
keyWindow(204) = 184
keyWindow(205) = 93
keyWindow(206) = 225
keyWindow(207) = 113
keyWindow(208) = 62
keyWindow(209) = 0
keyWindow(210) = 110
keyWindow(211) = 38
keyWindow(212) = 43
keyWindow(213) = 15
keyWindow(214) = 44
keyWindow(215) = 114
keyWindow(216) = 162
keyWindow(217) = 167
keyWindow(218) = 69
keyWindow(219) = 40
keyWindow(220) = 103
keyWindow(221) = 144
keyWindow(222) = 114
keyWindow(223) = 215
keyWindow(224) = 228
keyWindow(225) = 47
keyWindow(226) = 112
keyWindow(227) = 235
keyWindow(228) = 179
keyWindow(229) = 211
keyWindow(230) = 116
keyWindow(231) = 237
keyWindow(232) = 70
keyWindow(233) = 167
keyWindow(234) = 36
keyWindow(235) = 224
keyWindow(236) = 183
keyWindow(237) = 11
keyWindow(238) = 0
keyWindow(239) = 74
keyWindow(240) = 145
keyWindow(241) = 241
keyWindow(242) = 153
keyWindow(243) = 40
keyWindow(244) = 151
keyWindow(245) = 211
keyWindow(246) = 231
keyWindow(247) = 199
keyWindow(248) = 235
keyWindow(249) = 176
keyWindow(250) = 109
keyWindow(251) = 95
keyWindow(252) = 160
keyWindow(253) = 141
keyWindow(254) = 137
keyWindow(255) = 236
keyWindow(256) = 39
keyWindow(257) = 17
keyWindow(258) = 246
keyWindow(259) = 97
keyWindow(260) = 120
keyWindow(261) = 227
keyWindow(262) = 12
keyWindow(263) = 1
keyWindow(264) = 195
keyWindow(265) = 239
keyWindow(266) = 150
keyWindow(267) = 169
keyWindow(268) = 85
keyWindow(269) = 226
keyWindow(270) = 23
keyWindow(271) = 58
keyWindow(272) = 145
keyWindow(273) = 157
keyWindow(274) = 37
keyWindow(275) = 218
keyWindow(276) = 132
keyWindow(277) = 168
keyWindow(278) = 94
keyWindow(279) = 15
keyWindow(280) = 240
keyWindow(281) = 24
keyWindow(282) = 152
keyWindow(283) = 230
keyWindow(284) = 249
keyWindow(285) = 80
keyWindow(286) = 145
keyWindow(287) = 208
keyWindow(288) = 209
keyWindow(289) = 144
keyWindow(290) = 154
keyWindow(291) = 228
keyWindow(292) = 197
keyWindow(293) = 40
keyWindow(294) = 6
keyWindow(295) = 248
keyWindow(296) = 90
keyWindow(297) = 15
keyWindow(298) = 1
keyWindow(299) = 82
keyWindow(300) = 145
keyWindow(301) = 77
keyWindow(302) = 220
keyWindow(303) = 27
keyWindow(304) = 167
keyWindow(305) = 0
keyWindow(306) = 149
keyWindow(307) = 0
keyWindow(308) = 103
keyWindow(309) = 53
keyWindow(310) = 226
keyWindow(311) = 242
keyWindow(312) = 175
keyWindow(313) = 9
keyWindow(314) = 177
keyWindow(315) = 130
keyWindow(316) = 65
keyWindow(317) = 216
keyWindow(318) = 107
keyWindow(319) = 4
keyWindow(320) = 194
keyWindow(321) = 71
keyWindow(322) = 135
keyWindow(323) = 231
keyWindow(324) = 151
keyWindow(325) = 178
keyWindow(326) = 188
keyWindow(327) = 220
keyWindow(328) = 33
keyWindow(329) = 152
keyWindow(330) = 120
keyWindow(331) = 165
keyWindow(332) = 73
keyWindow(333) = 124
keyWindow(334) = 32
keyWindow(335) = 215
keyWindow(336) = 127
keyWindow(337) = 130
keyWindow(338) = 29
keyWindow(339) = 40
keyWindow(340) = 20
keyWindow(341) = 3
keyWindow(342) = 212
keyWindow(343) = 254
keyWindow(344) = 106
keyWindow(345) = 42
keyWindow(346) = 98
keyWindow(347) = 7
keyWindow(348) = 8
keyWindow(349) = 129
keyWindow(350) = 195
keyWindow(351) = 30
keyWindow(352) = 74
keyWindow(353) = 118
keyWindow(354) = 169
keyWindow(355) = 81
keyWindow(356) = 88
keyWindow(357) = 235
keyWindow(358) = 149
keyWindow(359) = 232
keyWindow(360) = 181
keyWindow(361) = 182
keyWindow(362) = 206
keyWindow(363) = 82
keyWindow(364) = 163
keyWindow(365) = 26
keyWindow(366) = 116
keyWindow(367) = 37
keyWindow(368) = 41
keyWindow(369) = 50
keyWindow(370) = 63
keyWindow(371) = 185
keyWindow(372) = 165
keyWindow(373) = 2
keyWindow(374) = 81
keyWindow(375) = 10
keyWindow(376) = 149
keyWindow(377) = 103
keyWindow(378) = 211
keyWindow(379) = 168
keyWindow(380) = 34
keyWindow(381) = 55
keyWindow(382) = 32
keyWindow(383) = 233
keyWindow(384) = 16
keyWindow(385) = 238
keyWindow(386) = 219
keyWindow(387) = 235
keyWindow(388) = 170
keyWindow(389) = 255
keyWindow(390) = 244
keyWindow(391) = 12
keyWindow(392) = 89
keyWindow(393) = 211
keyWindow(394) = 88
keyWindow(395) = 33
keyWindow(396) = 24
keyWindow(397) = 38
keyWindow(398) = 190
keyWindow(399) = 75
keyWindow(400) = 70
keyWindow(401) = 86
keyWindow(402) = 89
keyWindow(403) = 2
keyWindow(404) = 189
keyWindow(405) = 134
keyWindow(406) = 207
keyWindow(407) = 65
keyWindow(408) = 6
keyWindow(409) = 148
keyWindow(410) = 124
keyWindow(411) = 22
keyWindow(412) = 57
keyWindow(413) = 21
keyWindow(414) = 118
keyWindow(415) = 227
keyWindow(416) = 173
keyWindow(417) = 21
keyWindow(418) = 236
keyWindow(419) = 236
keyWindow(420) = 139
keyWindow(421) = 189
keyWindow(422) = 230
keyWindow(423) = 153
keyWindow(424) = 153
keyWindow(425) = 182
keyWindow(426) = 230
keyWindow(427) = 216
keyWindow(428) = 26
keyWindow(429) = 0
keyWindow(430) = 9
keyWindow(431) = 50
keyWindow(432) = 32
keyWindow(433) = 189
keyWindow(434) = 97
keyWindow(435) = 3
keyWindow(436) = 208
keyWindow(437) = 201
keyWindow(438) = 103
keyWindow(439) = 163
keyWindow(440) = 96
keyWindow(441) = 0
keyWindow(442) = 42
keyWindow(443) = 11
keyWindow(444) = 173
keyWindow(445) = 98
keyWindow(446) = 102
keyWindow(447) = 76
keyWindow(448) = 31
keyWindow(449) = 243
keyWindow(450) = 59
keyWindow(451) = 71
keyWindow(452) = 223
keyWindow(453) = 252
keyWindow(454) = 186
keyWindow(455) = 157
keyWindow(456) = 231
keyWindow(457) = 90
keyWindow(458) = 212
keyWindow(459) = 83
keyWindow(460) = 10
keyWindow(461) = 69
keyWindow(462) = 69
keyWindow(463) = 165
keyWindow(464) = 209
keyWindow(465) = 112
keyWindow(466) = 157
keyWindow(467) = 237
keyWindow(468) = 24
keyWindow(469) = 90
keyWindow(470) = 4
keyWindow(471) = 44
keyWindow(472) = 247
keyWindow(473) = 32
keyWindow(474) = 159
keyWindow(475) = 126
keyWindow(476) = 171
keyWindow(477) = 99
keyWindow(478) = 216
keyWindow(479) = 196
keyWindow(480) = 228
keyWindow(481) = 217
keyWindow(482) = 157
keyWindow(483) = 143
keyWindow(484) = 32
keyWindow(485) = 16
keyWindow(486) = 111
keyWindow(487) = 67
keyWindow(488) = 106
keyWindow(489) = 231
keyWindow(490) = 10
keyWindow(491) = 167
keyWindow(492) = 13
keyWindow(493) = 240
keyWindow(494) = 182
keyWindow(495) = 105
keyWindow(496) = 52
keyWindow(497) = 12
keyWindow(498) = 84
keyWindow(499) = 91
keyWindow(500) = 243
keyWindow(501) = 205
keyWindow(502) = 180
keyWindow(503) = 180
keyWindow(504) = 35
keyWindow(505) = 58
keyWindow(506) = 238
keyWindow(507) = 240
keyWindow(508) = 0
keyWindow(509) = 209
keyWindow(510) = 48
keyWindow(511) = 249
keyWindow(512) = 243
keyWindow(513) = 209
keyWindow(514) = 93
keyWindow(515) = 10
keyWindow(516) = 22
keyWindow(517) = 183
keyWindow(518) = 5
keyWindow(519) = 177
keyWindow(520) = 110
keyWindow(521) = 16
keyWindow(522) = 188
keyWindow(523) = 201
keyWindow(524) = 240
keyWindow(525) = 194
keyWindow(526) = 11
keyWindow(527) = 76
keyWindow(528) = 219
keyWindow(529) = 67
keyWindow(530) = 254
keyWindow(531) = 176
keyWindow(532) = 139
keyWindow(533) = 66
keyWindow(534) = 81
keyWindow(535) = 138
keyWindow(536) = 109
keyWindow(537) = 178
keyWindow(538) = 71
keyWindow(539) = 143
keyWindow(540) = 74
keyWindow(541) = 217
keyWindow(542) = 52
keyWindow(543) = 0
keyWindow(544) = 127
keyWindow(545) = 190
keyWindow(546) = 12
keyWindow(547) = 214
keyWindow(548) = 231
keyWindow(549) = 84
keyWindow(550) = 239
keyWindow(551) = 165
keyWindow(552) = 155
keyWindow(553) = 89
keyWindow(554) = 95
keyWindow(555) = 106
keyWindow(556) = 62
keyWindow(557) = 30
keyWindow(558) = 182
keyWindow(559) = 137
keyWindow(560) = 85
keyWindow(561) = 39
keyWindow(562) = 221
keyWindow(563) = 51
keyWindow(564) = 188
keyWindow(565) = 149
keyWindow(566) = 104
keyWindow(567) = 167
keyWindow(568) = 71
keyWindow(569) = 11
keyWindow(570) = 220
keyWindow(571) = 212
keyWindow(572) = 246
keyWindow(573) = 114
keyWindow(574) = 10
keyWindow(575) = 4
keyWindow(576) = 216
keyWindow(577) = 127
keyWindow(578) = 233
keyWindow(579) = 231
keyWindow(580) = 178
keyWindow(581) = 174
keyWindow(582) = 181
keyWindow(583) = 29
keyWindow(584) = 49
keyWindow(585) = 118
keyWindow(586) = 177
keyWindow(587) = 108
keyWindow(588) = 156
keyWindow(589) = 174
keyWindow(590) = 118
keyWindow(591) = 196
keyWindow(592) = 216
keyWindow(593) = 106
keyWindow(594) = 203
keyWindow(595) = 96
keyWindow(596) = 65
keyWindow(597) = 12
keyWindow(598) = 140
keyWindow(599) = 248
keyWindow(600) = 152
keyWindow(601) = 35
keyWindow(602) = 152
keyWindow(603) = 17
keyWindow(604) = 89
keyWindow(605) = 136
keyWindow(606) = 138
keyWindow(607) = 94
keyWindow(608) = 5
keyWindow(609) = 190
keyWindow(610) = 92
keyWindow(611) = 189
keyWindow(612) = 16
keyWindow(613) = 216
keyWindow(614) = 61
keyWindow(615) = 70
keyWindow(616) = 165
keyWindow(617) = 36
keyWindow(618) = 238
keyWindow(619) = 167
keyWindow(620) = 16
keyWindow(621) = 61
keyWindow(622) = 206
keyWindow(623) = 140
keyWindow(624) = 226
keyWindow(625) = 251
keyWindow(626) = 37
keyWindow(627) = 225
keyWindow(628) = 211
keyWindow(629) = 111
keyWindow(630) = 42
keyWindow(631) = 195
keyWindow(632) = 36
keyWindow(633) = 248
keyWindow(634) = 233
keyWindow(635) = 67
keyWindow(636) = 146
keyWindow(637) = 100
keyWindow(638) = 244
keyWindow(639) = 23
keyWindow(640) = 154
keyWindow(641) = 103
keyWindow(642) = 48
keyWindow(643) = 4
keyWindow(644) = 15
keyWindow(645) = 33
keyWindow(646) = 169
keyWindow(647) = 151
keyWindow(648) = 13
keyWindow(649) = 151
keyWindow(650) = 115
keyWindow(651) = 173
keyWindow(652) = 37
keyWindow(653) = 103
keyWindow(654) = 172
keyWindow(655) = 23
keyWindow(656) = 182
keyWindow(657) = 29
keyWindow(658) = 22
keyWindow(659) = 25
keyWindow(660) = 54
keyWindow(661) = 46
keyWindow(662) = 188
keyWindow(663) = 14
keyWindow(664) = 24
keyWindow(665) = 12
keyWindow(666) = 182
keyWindow(667) = 241
keyWindow(668) = 163
keyWindow(669) = 90
keyWindow(670) = 121
keyWindow(671) = 172
keyWindow(672) = 29
keyWindow(673) = 73
keyWindow(674) = 191
keyWindow(675) = 91
keyWindow(676) = 232
keyWindow(677) = 229
keyWindow(678) = 197
keyWindow(679) = 200
keyWindow(680) = 32
keyWindow(681) = 7
keyWindow(682) = 67
keyWindow(683) = 214
keyWindow(684) = 141
keyWindow(685) = 248
keyWindow(686) = 10
keyWindow(687) = 135
keyWindow(688) = 168
keyWindow(689) = 4
keyWindow(690) = 144
keyWindow(691) = 17
keyWindow(692) = 94
keyWindow(693) = 228
keyWindow(694) = 76
keyWindow(695) = 202
keyWindow(696) = 130
keyWindow(697) = 174
keyWindow(698) = 251
keyWindow(699) = 170
keyWindow(700) = 100
keyWindow(701) = 173
keyWindow(702) = 232
keyWindow(703) = 183
keyWindow(704) = 132
keyWindow(705) = 130
keyWindow(706) = 35
keyWindow(707) = 163
keyWindow(708) = 1
keyWindow(709) = 154
keyWindow(710) = 134
keyWindow(711) = 56
keyWindow(712) = 202
keyWindow(713) = 13
keyWindow(714) = 190
keyWindow(715) = 224
keyWindow(716) = 56
keyWindow(717) = 107
keyWindow(718) = 107
keyWindow(719) = 244
keyWindow(720) = 16
keyWindow(721) = 12
keyWindow(722) = 149
keyWindow(723) = 220
keyWindow(724) = 120
keyWindow(725) = 245
keyWindow(726) = 179
keyWindow(727) = 103
keyWindow(728) = 85
keyWindow(729) = 255
keyWindow(730) = 195
keyWindow(731) = 187
keyWindow(732) = 191
keyWindow(733) = 82
keyWindow(734) = 225
keyWindow(735) = 13
keyWindow(736) = 206
keyWindow(737) = 106
keyWindow(738) = 60
keyWindow(739) = 212
keyWindow(740) = 12
keyWindow(741) = 211
keyWindow(742) = 247
keyWindow(743) = 112
keyWindow(744) = 185
keyWindow(745) = 5
keyWindow(746) = 56
keyWindow(747) = 226
keyWindow(748) = 236
keyWindow(749) = 179
keyWindow(750) = 181
keyWindow(751) = 208
keyWindow(752) = 204
keyWindow(753) = 16
keyWindow(754) = 159
keyWindow(755) = 158
keyWindow(756) = 36
keyWindow(757) = 65
keyWindow(758) = 101
keyWindow(759) = 148
keyWindow(760) = 23
keyWindow(761) = 89
keyWindow(762) = 125
keyWindow(763) = 27
keyWindow(764) = 61
keyWindow(765) = 117
keyWindow(766) = 255
keyWindow(767) = 142
keyWindow(768) = 32
keyWindow(769) = 138
keyWindow(770) = 105
keyWindow(771) = 166
keyWindow(772) = 203
keyWindow(773) = 253
keyWindow(774) = 113
keyWindow(775) = 138
keyWindow(776) = 30
keyWindow(777) = 247
keyWindow(778) = 250
keyWindow(779) = 198
keyWindow(780) = 21
keyWindow(781) = 244
keyWindow(782) = 113
keyWindow(783) = 40
keyWindow(784) = 161
keyWindow(785) = 229
keyWindow(786) = 179
keyWindow(787) = 100
keyWindow(788) = 76
keyWindow(789) = 30
keyWindow(790) = 177
keyWindow(791) = 69
keyWindow(792) = 87
keyWindow(793) = 90
keyWindow(794) = 9
keyWindow(795) = 135
keyWindow(796) = 254
keyWindow(797) = 108
keyWindow(798) = 99
keyWindow(799) = 145
keyWindow(800) = 195
keyWindow(801) = 145
keyWindow(802) = 138
keyWindow(803) = 223
keyWindow(804) = 237
keyWindow(805) = 52
keyWindow(806) = 126
keyWindow(807) = 244
keyWindow(808) = 109
keyWindow(809) = 171
keyWindow(810) = 44
keyWindow(811) = 0
keyWindow(812) = 187
keyWindow(813) = 129
keyWindow(814) = 127
keyWindow(815) = 49
keyWindow(816) = 220
keyWindow(817) = 100
keyWindow(818) = 253
keyWindow(819) = 0
keyWindow(820) = 116
keyWindow(821) = 93
keyWindow(822) = 87
keyWindow(823) = 39
keyWindow(824) = 245
keyWindow(825) = 5
keyWindow(826) = 54
keyWindow(827) = 203
keyWindow(828) = 241
keyWindow(829) = 155
keyWindow(830) = 255
keyWindow(831) = 125
keyWindow(832) = 80
keyWindow(833) = 253
keyWindow(834) = 75
keyWindow(835) = 71
keyWindow(836) = 242
keyWindow(837) = 147
keyWindow(838) = 153
keyWindow(839) = 148
keyWindow(840) = 214
keyWindow(841) = 91
keyWindow(842) = 33
keyWindow(843) = 181
keyWindow(844) = 78
keyWindow(845) = 10
keyWindow(846) = 82
keyWindow(847) = 171
keyWindow(848) = 89
keyWindow(849) = 179
keyWindow(850) = 221
keyWindow(851) = 144
keyWindow(852) = 224
keyWindow(853) = 138
keyWindow(854) = 112
keyWindow(855) = 254
keyWindow(856) = 152
keyWindow(857) = 186
keyWindow(858) = 190
keyWindow(859) = 224
keyWindow(860) = 44
keyWindow(861) = 251
keyWindow(862) = 60
keyWindow(863) = 133
keyWindow(864) = 65
keyWindow(865) = 70
keyWindow(866) = 72
keyWindow(867) = 203
keyWindow(868) = 126
keyWindow(869) = 123
keyWindow(870) = 212
keyWindow(871) = 108
keyWindow(872) = 68
keyWindow(873) = 185
keyWindow(874) = 42
keyWindow(875) = 208
keyWindow(876) = 51
keyWindow(877) = 11
keyWindow(878) = 177
keyWindow(879) = 3
keyWindow(880) = 24
keyWindow(881) = 207
keyWindow(882) = 14
keyWindow(883) = 148
keyWindow(884) = 113
keyWindow(885) = 55
keyWindow(886) = 1
keyWindow(887) = 19
keyWindow(888) = 179
keyWindow(889) = 31
keyWindow(890) = 133
keyWindow(891) = 11
keyWindow(892) = 227
keyWindow(893) = 72
keyWindow(894) = 145
keyWindow(895) = 242
keyWindow(896) = 157
keyWindow(897) = 244
keyWindow(898) = 239
keyWindow(899) = 129
keyWindow(900) = 124
keyWindow(901) = 109
keyWindow(902) = 56
keyWindow(903) = 134
keyWindow(904) = 56
keyWindow(905) = 95
keyWindow(906) = 110
keyWindow(907) = 161
keyWindow(908) = 73
keyWindow(909) = 151
keyWindow(910) = 136
keyWindow(911) = 67
keyWindow(912) = 176
keyWindow(913) = 201
keyWindow(914) = 193
keyWindow(915) = 70
keyWindow(916) = 53
keyWindow(917) = 31
keyWindow(918) = 238
keyWindow(919) = 84
keyWindow(920) = 81
keyWindow(921) = 65
keyWindow(922) = 50
keyWindow(923) = 182
keyWindow(924) = 20
keyWindow(925) = 17
keyWindow(926) = 247
keyWindow(927) = 179
keyWindow(928) = 217
keyWindow(929) = 14
keyWindow(930) = 34
keyWindow(931) = 182
keyWindow(932) = 97
keyWindow(933) = 55
keyWindow(934) = 117
keyWindow(935) = 176
keyWindow(936) = 108
keyWindow(937) = 234
keyWindow(938) = 147
keyWindow(939) = 89
keyWindow(940) = 168
keyWindow(941) = 7
keyWindow(942) = 251
keyWindow(943) = 212
keyWindow(944) = 22
keyWindow(945) = 107
keyWindow(946) = 63
keyWindow(947) = 248
keyWindow(948) = 179
keyWindow(949) = 222
keyWindow(950) = 167
keyWindow(951) = 214
keyWindow(952) = 136
keyWindow(953) = 74
keyWindow(954) = 53
keyWindow(955) = 47
keyWindow(956) = 120
keyWindow(957) = 233
keyWindow(958) = 131
keyWindow(959) = 41
keyWindow(960) = 167
keyWindow(961) = 220
keyWindow(962) = 56
keyWindow(963) = 12
keyWindow(964) = 51
keyWindow(965) = 125
keyWindow(966) = 207
keyWindow(967) = 112
keyWindow(968) = 179
keyWindow(969) = 211
keyWindow(970) = 47
keyWindow(971) = 134
keyWindow(972) = 223
keyWindow(973) = 112
keyWindow(974) = 223
keyWindow(975) = 46
keyWindow(976) = 249
keyWindow(977) = 24
keyWindow(978) = 64
keyWindow(979) = 58
keyWindow(980) = 36
keyWindow(981) = 187
keyWindow(982) = 77
keyWindow(983) = 132
keyWindow(984) = 116
keyWindow(985) = 116
keyWindow(986) = 111
keyWindow(987) = 36
keyWindow(988) = 127
keyWindow(989) = 217
keyWindow(990) = 177
keyWindow(991) = 24
keyWindow(992) = 58
keyWindow(993) = 102
keyWindow(994) = 166
keyWindow(995) = 105
keyWindow(996) = 119
keyWindow(997) = 234
keyWindow(998) = 187
keyWindow(999) = 198
keyWindow(1000) = 77
keyWindow(1001) = 153
keyWindow(1002) = 23
keyWindow(1003) = 157
keyWindow(1004) = 103
keyWindow(1005) = 92
keyWindow(1006) = 33
keyWindow(1007) = 136
keyWindow(1008) = 182
keyWindow(1009) = 131
keyWindow(1010) = 154
keyWindow(1011) = 141
keyWindow(1012) = 149
keyWindow(1013) = 4
keyWindow(1014) = 117
keyWindow(1015) = 213
keyWindow(1016) = 226
keyWindow(1017) = 64
keyWindow(1018) = 116
keyWindow(1019) = 55
keyWindow(1020) = 6
keyWindow(1021) = 159
keyWindow(1022) = 126
keyWindow(1023) = 225
    
    i = 0
    j = 0
End Sub

Private Function Shift(ByVal lValue As Long, ByVal lNumberOfBitsToShift As Long, ByVal lDirectionToShift As Long) As Long
Const ksCallname As String = "Shift"
Dim LShift As Long
On Error GoTo Procedure_Error

    If lDirectionToShift Then
        LShift = lValue * (2 ^ lNumberOfBitsToShift)
    Else
        LShift = lValue \ (2 ^ lNumberOfBitsToShift)
    End If
    
Procedure_Exit:
    Shift = LShift
    Exit Function
    
Procedure_Error:
    Err.Raise Err.Number, ksCallname, Err.Description, Err.HelpFile, Err.HelpContext
    Resume Procedure_Exit
End Function

Private Function LShift(ByVal lValue As Long, ByVal lNumberOfBitsToShift As Long) As Long
Const ksCallname As String = "LShift"
On Error GoTo Procedure_Error

    LShift = Shift(lValue, lNumberOfBitsToShift, -1)
    
Procedure_Exit:
    Exit Function
    
Procedure_Error:
    Err.Raise Err.Number, ksCallname, Err.Description, Err.HelpFile, Err.HelpContext
    Resume Procedure_Exit
End Function

Private Function RShift(ByVal lValue As Long, ByVal lNumberOfBitsToShift As Long) As Long
Const ksCallname As String = "LShift"
On Error GoTo Procedure_Error

    RShift = Shift(lValue, lNumberOfBitsToShift, 0)
    
Procedure_Exit:
    Exit Function
    
Procedure_Error:
    Err.Raise Err.Number, ksCallname, Err.Description, Err.HelpFile, Err.HelpContext
    Resume Procedure_Exit
End Function

