├── .idea
├── .name
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── Data
└── KeystrokeData.csv
├── Images
├── Confusion.png
├── Data.png
├── Keytimings.png
└── Result.png
├── Jupyter Notebooks
├── .ipynb_checkpoints
│ ├── KNearestNeighbourModel-checkpoint.ipynb
│ ├── LogisticRegressionModel-checkpoint.ipynb
│ └── SVMSingleUser-checkpoint.ipynb
├── KNearestNeighbourModel.ipynb
├── Keystroke.ipynb
└── LogisticRegressionModel.ipynb
├── KeystrokeLoggingApplication.jar
├── KeystrokeLoggingApplication
├── .idea
│ ├── KeystrokeLoggingApplication.iml
│ ├── misc.xml
│ ├── modules.xml
│ └── workspace.xml
├── KeystrokeLoggingApplication.iml
├── Keystrokes.csv
├── KeystrokesInNano.csv
├── out
│ ├── artifacts
│ │ └── KeystrokeLoggingApplication_jar
│ │ │ ├── KeystrokeLoggingApplication 2.jar
│ │ │ ├── KeystrokeLoggingApplication.jar
│ │ │ ├── Keystrokes.csv
│ │ │ └── KeystrokesInNano.csv
│ └── production
│ │ └── KeystrokeLoggingApplication
│ │ ├── KeyDataStore.class
│ │ ├── KeyEventDemo$1.class
│ │ ├── KeyEventDemo.class
│ │ ├── META-INF
│ │ └── MANIFEST.MF
│ │ └── TypedKeyObject.class
└── src
│ ├── KeyDataStore.java
│ ├── KeyEventDemo.java
│ ├── META-INF
│ └── MANIFEST.MF
│ └── TypedKeyObject.java
├── README.md
├── User Authentication Application
├── .idea
│ ├── artifacts
│ │ └── Keystroke_App_50_50_6_2_2_jar.xml
│ ├── kotlinc.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── workspace.xml
├── Keystroke App 50-50.6-2-2.iml
├── lib
│ └── json-simple-1.1.1.jar
├── out
│ ├── artifacts
│ │ └── Keystroke_App_50_50_6_2_2_jar
│ │ │ ├── Keystroke App 50-50.6-2-2.jar
│ │ │ └── UserAuthenticationApplication.jar
│ └── production
│ │ └── Keystroke App 50-50.6-2-2
│ │ ├── KeyDataStore.class
│ │ ├── KeyEventDemo$1.class
│ │ ├── KeyEventDemo$2.class
│ │ ├── KeyEventDemo.class
│ │ ├── META-INF
│ │ └── MANIFEST.MF
│ │ └── TypedKeyObject.class
└── src
│ ├── KeyDataStore.java
│ ├── KeyEventDemo.java
│ ├── META-INF
│ └── MANIFEST.MF
│ └── TypedKeyObject.java
└── UserAuthenticationApplication.jar
/.idea/.name:
--------------------------------------------------------------------------------
1 | User-Authentication-Application
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 | 1535091261114
291 |
292 |
293 | 1535091261114
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
--------------------------------------------------------------------------------
/Images/Confusion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/Images/Confusion.png
--------------------------------------------------------------------------------
/Images/Data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/Images/Data.png
--------------------------------------------------------------------------------
/Images/Keytimings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/Images/Keytimings.png
--------------------------------------------------------------------------------
/Images/Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/Images/Result.png
--------------------------------------------------------------------------------
/Jupyter Notebooks/.ipynb_checkpoints/SVMSingleUser-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 5,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "import pandas as pd\n",
10 | "import numpy as np\n",
11 | "import matplotlib.pyplot as plt\n",
12 | "import seaborn as sns\n",
13 | "%matplotlib inline\n",
14 | "from matplotlib.colors import ListedColormap\n",
15 | "from sklearn.model_selection import train_test_split\n",
16 | "from sklearn import metrics\n",
17 | "from sklearn.preprocessing import StandardScaler\n",
18 | "from sklearn.metrics import classification_report,confusion_matrix\n"
19 | ]
20 | },
21 | {
22 | "cell_type": "code",
23 | "execution_count": 7,
24 | "metadata": {},
25 | "outputs": [],
26 | "source": [
27 | "data = pd.read_csv(\"KeystrokeData.csv\")\n",
28 | "train, test = train_test_split(data, test_size = 0.4, random_state=42)\n",
29 | "features = list(data.columns[3:34])\n",
30 | "\n",
31 | "\n",
32 | "X_train = train[features]\n",
33 | "y_train = train['Target']\n",
34 | "X_test = test[features]\n",
35 | "y_test = test['Target']\n"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": 8,
41 | "metadata": {},
42 | "outputs": [
43 | {
44 | "data": {
45 | "text/plain": [
46 | "['UD.period.t',\n",
47 | " 'H.t',\n",
48 | " 'DD.t.i',\n",
49 | " 'UD.t.i',\n",
50 | " 'H.i',\n",
51 | " 'DD.i.e',\n",
52 | " 'UD.i.e',\n",
53 | " 'H.e',\n",
54 | " 'DD.e.five',\n",
55 | " 'UD.e.five',\n",
56 | " 'H.five',\n",
57 | " 'DD.five.Shift.r',\n",
58 | " 'UD.five.Shift.r',\n",
59 | " 'H.Shift.r',\n",
60 | " 'DD.Shift.r.o',\n",
61 | " 'UD.Shift.r.o',\n",
62 | " 'H.o',\n",
63 | " 'DD.o.a',\n",
64 | " 'UD.o.a',\n",
65 | " 'H.a',\n",
66 | " 'DD.a.n',\n",
67 | " 'UD.a.n',\n",
68 | " 'H.n',\n",
69 | " 'DD.n.l',\n",
70 | " 'UD.n.l',\n",
71 | " 'H.l',\n",
72 | " 'DD.l.Return',\n",
73 | " 'UD.l.Return',\n",
74 | " 'H.Return',\n",
75 | " 'Target']"
76 | ]
77 | },
78 | "execution_count": 8,
79 | "metadata": {},
80 | "output_type": "execute_result"
81 | }
82 | ],
83 | "source": [
84 | "features"
85 | ]
86 | },
87 | {
88 | "cell_type": "code",
89 | "execution_count": 9,
90 | "metadata": {},
91 | "outputs": [
92 | {
93 | "data": {
94 | "text/plain": [
95 | ""
96 | ]
97 | },
98 | "execution_count": 9,
99 | "metadata": {},
100 | "output_type": "execute_result"
101 | },
102 | {
103 | "data": {
104 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAEQtJREFUeJzt3XuwXWV9xvHvYwCRooAkIE2gUYwKWhSMlKmOVXAc76QKXgotKh3UopXaUantWLB2imNbFGpVKgo4KlJUQEtF5eJdMFwEAZHAcMmAEOSieIEiv/6x38gmvEn2idlnn+R8PzNn9lrvetfavzNZJ89+122nqpAkaVUPm3QBkqSZyYCQJHUZEJKkLgNCktRlQEiSugwISVKXASFJ6jIgJEldBoQkqWuTSRfwu5g7d24tX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A89YTb/LgScm2bE9kO5VQ8vOAv565UyS3dvkqk/LlSbKgJCm5n+ALdohpnezmieLVtUvgTcDXwO+yeAb0u5qi49s27gsyeXAEa39HOCp7cS1J6k1cT6LSRqTJFtW1d1tBPFR4LKqOnbSdUmjcgQhjc+b2onoK4BHAP814XqkKXEEIUnqcgQhSeoyICRJXQaEJKnLgJAkdRkQkqQuA0KS1PX/kZkRy/RVhVMAAAAASUVORK5CYII=\n",
105 | "text/plain": [
106 | ""
107 | ]
108 | },
109 | "metadata": {},
110 | "output_type": "display_data"
111 | }
112 | ],
113 | "source": [
114 | "sns.countplot(x='Target',data=train,palette='RdBu_r')"
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": 11,
120 | "metadata": {},
121 | "outputs": [
122 | {
123 | "ename": "ValueError",
124 | "evalue": "could not convert string to float: 'Imposter'",
125 | "output_type": "error",
126 | "traceback": [
127 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
128 | "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
129 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0msklearn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msvm\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSVC\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mmodel\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSVC\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX_train\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0my_train\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mpredictions\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX_test\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
130 | "\u001b[0;32m/anaconda3/lib/python3.6/site-packages/sklearn/svm/base.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, X, y, sample_weight)\u001b[0m\n\u001b[1;32m 147\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_sparse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msparse\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mcallable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkernel\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 148\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 149\u001b[0;31m \u001b[0mX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcheck_X_y\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'C'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maccept_sparse\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'csr'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 150\u001b[0m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_validate_targets\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 151\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
131 | "\u001b[0;32m/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py\u001b[0m in \u001b[0;36mcheck_X_y\u001b[0;34m(X, y, accept_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)\u001b[0m\n\u001b[1;32m 571\u001b[0m X = check_array(X, accept_sparse, dtype, order, copy, force_all_finite,\n\u001b[1;32m 572\u001b[0m \u001b[0mensure_2d\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mallow_nd\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mensure_min_samples\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 573\u001b[0;31m ensure_min_features, warn_on_dtype, estimator)\n\u001b[0m\u001b[1;32m 574\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmulti_output\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 575\u001b[0m y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,\n",
132 | "\u001b[0;32m/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py\u001b[0m in \u001b[0;36mcheck_array\u001b[0;34m(array, accept_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)\u001b[0m\n\u001b[1;32m 431\u001b[0m force_all_finite)\n\u001b[1;32m 432\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 433\u001b[0;31m \u001b[0marray\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdtype\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0morder\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0morder\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 434\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 435\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mensure_2d\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
133 | "\u001b[0;31mValueError\u001b[0m: could not convert string to float: 'Imposter'"
134 | ]
135 | }
136 | ],
137 | "source": [
138 | "from sklearn.svm import SVC\n",
139 | "model = SVC()\n",
140 | "model.fit(X_train,y_train)\n",
141 | "predictions = model.predict(X_test)"
142 | ]
143 | },
144 | {
145 | "cell_type": "code",
146 | "execution_count": 12,
147 | "metadata": {},
148 | "outputs": [
149 | {
150 | "ename": "NameError",
151 | "evalue": "name 'predictions' is not defined",
152 | "output_type": "error",
153 | "traceback": [
154 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
155 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
156 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mcm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconfusion_matrix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0my_test\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mpredictions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mconfusion_matrix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0my_test\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mpredictions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
157 | "\u001b[0;31mNameError\u001b[0m: name 'predictions' is not defined"
158 | ]
159 | }
160 | ],
161 | "source": [
162 | "cm = confusion_matrix(y_test,predictions)\n",
163 | "print(confusion_matrix(y_test,predictions))\n"
164 | ]
165 | },
166 | {
167 | "cell_type": "code",
168 | "execution_count": 13,
169 | "metadata": {
170 | "scrolled": true
171 | },
172 | "outputs": [
173 | {
174 | "ename": "NameError",
175 | "evalue": "name 'predictions' is not defined",
176 | "output_type": "error",
177 | "traceback": [
178 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
179 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
180 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclassification_report\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0my_test\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mpredictions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
181 | "\u001b[0;31mNameError\u001b[0m: name 'predictions' is not defined"
182 | ]
183 | }
184 | ],
185 | "source": [
186 | "print(classification_report(y_test,predictions))"
187 | ]
188 | },
189 | {
190 | "cell_type": "code",
191 | "execution_count": 50,
192 | "metadata": {},
193 | "outputs": [
194 | {
195 | "name": "stdout",
196 | "output_type": "stream",
197 | "text": [
198 | "Accuracy of Model is : 0.8153846153846154\n",
199 | "Error Rate : 0.18461538461538463\n"
200 | ]
201 | }
202 | ],
203 | "source": [
204 | "model_accuracy = metrics.accuracy_score(y_test,predictions)\n",
205 | "print('Accuracy of Model is : ',model_accuracy)\n",
206 | "print('Error Rate :', 1-model_accuracy)\n"
207 | ]
208 | },
209 | {
210 | "cell_type": "code",
211 | "execution_count": 51,
212 | "metadata": {},
213 | "outputs": [
214 | {
215 | "data": {
216 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEWCAYAAADcnKq+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAHENJREFUeJzt3Xl8XGW9x/HPN+mS7i3d2CktS5VKWVousllQUF4qVBHhCijIpbLIvgpckUXBexEUBBGtcAEBpRewF5SCyFpApCwCymILZWmBLlDoQrf87h/nJEySyWSSTpI+5Pt+vfLqzDlnnuc3meTb5zxz5okiAjOzFFR1dgFmZuVyYJlZMhxYZpYMB5aZJcOBZWbJcGCZWTIcWNYhJPWS9H+SFkm6ZQ3aOUjS3ZWsrTNI+pOkb3V2HalxYFkDkr4h6QlJiyXNzX+xdqlA018DhgODI2L/tjYSEb+NiL0qUE8DkiZICkm3Nto+Nt9+f5nt/EDSDS0dFxF7R8T/tLHcLsuBZfUknQT8FPgRWbhsDFwJ7FuB5jcBXoqIVRVoq73MA3aSNLhg27eAlyrVgTL+vWuriPCXvwAGAIuB/Usc05Ms0ObkXz8Feub7JgBvACcD7wBzgcPyfecCK4CVeR+HAz8AbihoewQQQLf8/qHALOAD4BXgoILtDxc8bifgb8Ci/N+dCvbdD5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bYtmSBOL6Mp3NrRIzP+/sn2YoYdUaQrarwRbKr0GsoWDEjb/8ISZuW0Y+1gj+aY5XQK18JArIR1mRgfRquCLAj8EmypW8AepCtODAaeCUiXgaQdAMwqUgfewDfBIiI1cAiSYMaHdPc6gT9gNsiYmnex9QyntMYSReQnXb2JftcXp1iqyrsRfEVM14qoy8rkwPLKmFZ3RpMdfJQKlwRQMA9EfHvjY7bhqarFLRVc6sTnNCGPq4FJkbEM5IOBSYU7GtuVYViK2aMaGW/VoJPCa2jPAbsrGxROiT1zlcfeAHYNF+hAODfm3n8vcBR+WOrJfWn/NUJHgS+IqmXpH5kp58t6QfMzVfAOKjRvmKrKrRlxQxrJY+wrENExLx8pHKTslVRAc6OiJckTQLulDSfbHHBMUWaOB64WtLhZKsNHBURj5azOkFEPCnpd8DTZIsdPlRGyf9JtorFbLI5ucJgLLaqwq9p/YoZ1kr+LKGZJcOnhGaWDAeWmSXDgWVmyXBgmVkyHFhmlgwHlpklw4FlZsn4f3DHssmLGNR/AAAAAElFTkSuQmCC\n",
217 | "text/plain": [
218 | ""
219 | ]
220 | },
221 | "metadata": {},
222 | "output_type": "display_data"
223 | }
224 | ],
225 | "source": [
226 | "plt.clf()\n",
227 | "plt.imshow(cm,interpolation='nearest', cmap=plt.cm.coolwarm)\n",
228 | "classNames = ['Genuine','Imposter']\n",
229 | "plt.title('Confusion Matrix')\n",
230 | "plt.ylabel('True label')\n",
231 | "plt.xlabel('Predicted label')\n",
232 | "tick_marks = np.arange(len(classNames))\n",
233 | "plt.xticks(tick_marks, classNames)\n",
234 | "plt.yticks(tick_marks, classNames)\n",
235 | "s = [['TP','FN'], ['FP', 'TN']]\n",
236 | "for i in range(2):\n",
237 | " for j in range(2):\n",
238 | " plt.text(j,i, str(s[i][j])+\" = \"+str(cm[i][j]))\n",
239 | "plt.show()"
240 | ]
241 | },
242 | {
243 | "cell_type": "code",
244 | "execution_count": 52,
245 | "metadata": {},
246 | "outputs": [
247 | {
248 | "data": {
249 | "text/plain": [
250 | ""
251 | ]
252 | },
253 | "execution_count": 52,
254 | "metadata": {},
255 | "output_type": "execute_result"
256 | },
257 | {
258 | "data": {
259 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAEwtJREFUeJzt3X20XXV95/H3x8SHWqxAc6GUkAkw0RYcDHrL6qqV4sNYdFpF6wMMdrA6E3CkU+ehU2u7FG1d4xq1ropWGkdEZwmVQqF0hgqUWqhWxQRTCEgUmICRFK6kVakONPDtH2dfc3L9JTk35Jx9w32/1jrr7v3bv332967sm8/57aeTqkKSpLke13cBkqSFyYCQJDUZEJKkJgNCktRkQEiSmgwISVKTASFJajIgJElNBoQkqWlp3wU8GsuWLauVK1f2XYYk7VfWr1//zaqa2lO//TogVq5cybp16/ouQ5L2K0nuGqWfh5gkSU1jC4gk5ye5L8nGobZPJdnQvTYn2dC1r0zyvaFl542rLknSaMZ5iOkC4IPAJ2Ybquo1s9NJ3gd8a6j/HVW1eoz1SJLmYWwBUVXXJ1nZWpYkwKuB549r+5KkR6evcxDPBe6tqq8NtR2Z5MtJrkvy3J7qkiR1+rqK6TTgoqH5rcCKqro/ybOBy5McW1XfnrtikjXAGoAVK1ZMpFhJWowmPoJIshR4BfCp2baqerCq7u+m1wN3AE9rrV9Va6tquqqmp6b2eBmvJGkv9XGI6YXAbVW1ZbYhyVSSJd30UcAq4M4eapMkdcZ5metFwOeBpyfZkuQN3aJT2fnwEsCJwE1J/ha4BDirqraNqzZJ0p6N8yqm03bR/rpG26XApeOqRdofffMvLuy7BC1Ay174bye2Le+kliQ1GRCSpCYDQpLUZEBIkpoMCElSkwEhSWoyICRJTQaEJKnJgJAkNRkQkqQmA0KS1GRASJKaDAhJU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d+BUMBFQ+u/iMGTcjcAn2Hw8LkVE6lcmgdHENI8JHkhcCLw01X1vSSfZcfTRb9XO+48bT4ld2jZKVV1x5z3PnGfFyw9Co4gpPl5KrCtC4djgZ/aRb9bgKcnOaJ7IN1rhpZdBfyn2Zkkx3eTc5+WK/XKgJDm5/8CT+4OMb2NXTxZtKq+C5wN/AXw1wy+Ie1b3eJ3dO9xc5JbgHO69r8EntmduPYktXrns5ikMUlyQFU90I0g/hC4uarO7bsuaVSOIKTxeWN3IvpW4IeAj/RcjzQvjiAkSU2OICRJTQaEJKnJgJAkNRkQkqQmA0KS1GRASJKa/hlLVfrPUmzLdQAAAABJRU5ErkJggg==\n",
260 | "text/plain": [
261 | ""
262 | ]
263 | },
264 | "metadata": {},
265 | "output_type": "display_data"
266 | }
267 | ],
268 | "source": [
269 | "sns.countplot(x='Target',data=test,palette='RdBu_r')"
270 | ]
271 | },
272 | {
273 | "cell_type": "code",
274 | "execution_count": 53,
275 | "metadata": {},
276 | "outputs": [
277 | {
278 | "ename": "AttributeError",
279 | "evalue": "predict_proba is not available when probability=False",
280 | "output_type": "error",
281 | "traceback": [
282 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
283 | "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
284 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0my_pred_proba\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpredict_proba\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX_test\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
285 | "\u001b[0;32m/anaconda3/lib/python3.6/site-packages/sklearn/svm/base.py\u001b[0m in \u001b[0;36mpredict_proba\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 588\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 589\u001b[0m \"\"\"\n\u001b[0;32m--> 590\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_check_proba\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 591\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_predict_proba\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 592\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
286 | "\u001b[0;32m/anaconda3/lib/python3.6/site-packages/sklearn/svm/base.py\u001b[0m in \u001b[0;36m_check_proba\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 555\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_check_proba\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 556\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprobability\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 557\u001b[0;31m raise AttributeError(\"predict_proba is not available when \"\n\u001b[0m\u001b[1;32m 558\u001b[0m \" probability=False\")\n\u001b[1;32m 559\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_impl\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m'c_svc'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'nu_svc'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
287 | "\u001b[0;31mAttributeError\u001b[0m: predict_proba is not available when probability=False"
288 | ]
289 | }
290 | ],
291 | "source": [
292 | "y_pred_proba = model.predict_proba(X_test)\n"
293 | ]
294 | },
295 | {
296 | "cell_type": "code",
297 | "execution_count": null,
298 | "metadata": {},
299 | "outputs": [],
300 | "source": []
301 | }
302 | ],
303 | "metadata": {
304 | "kernelspec": {
305 | "display_name": "Python 3",
306 | "language": "python",
307 | "name": "python3"
308 | },
309 | "language_info": {
310 | "codemirror_mode": {
311 | "name": "ipython",
312 | "version": 3
313 | },
314 | "file_extension": ".py",
315 | "mimetype": "text/x-python",
316 | "name": "python",
317 | "nbconvert_exporter": "python",
318 | "pygments_lexer": "ipython3",
319 | "version": "3.6.4"
320 | }
321 | },
322 | "nbformat": 4,
323 | "nbformat_minor": 2
324 | }
325 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/KeystrokeLoggingApplication.jar
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/.idea/KeystrokeLoggingApplication.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 | 1535076700811
470 |
471 |
472 | 1535076700811
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/KeystrokeLoggingApplication.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/Keystrokes.csv:
--------------------------------------------------------------------------------
1 | User,H.period,DD.period.t,UD.period.t,H.t,DD.t.i,UD.t.i,H.i,DD.i.e,UD.i.e,H.e,DD.e.five,UD.e.five,H.five,DD.five.Shift.r,UD.five.Shift.r,H.Shift.r,DD.Shift.r.o,UD.Shift.r.o,H.o,DD.o.a,UD.o.a,H.a,DD.a.n,UD.a.n,H.n,DD.n.l,UD.n.l,H.l,DD.l.Return,UD.l.Return,H.Return
2 | ,0.099,0.196,0.097,0.094,0.127,0.033,0.127,0.144,0.017,0.127,0.248,0.121,0.087,0.289,0.202,0.206,0.159,-0.047,0.111,0.144,0.033,0.111,0.152,0.041,0.119,0.104,-0.015,0.183,0.096,-0.087,0.159
3 | ,0.097,0.05,-0.047,0.079,0.161,0.082,0.078,0.096,0.018,0.118,0.095,-0.023,0.127,0.08,-0.047,0.143
4 | ,0.127,0.088,-0.039,0.086,0.176,0.09,0.071,0.048,-0.023,0.142,0.136,-0.006,0.167,0.112,-0.055,0.135
5 | ,0.119,0.08,-0.039,0.111,0.208,0.097,0.143,0.136,-0.007,0.095,0.12,0.025,0.191,0.12,-0.071,0.151
6 | ,0.053,0.159,0.106,0.086,0.135,0.049,0.104,0.145,0.041,0.119,0.272,0.153,0.079,0.352,0.273,0.175,0.152,-0.023,0.103,0.128,0.025,0.119,0.136,0.017,0.127,0.192,0.065,0.167,0.104,-0.063,0.135
7 | ,0.107,0.22,0.113,0.103,0.16,0.057,0.111,0.168,0.057,0.111,0.288,0.177,0.087,0.288,0.201,0.208,0.192,-0.016,0.095,0.12,0.025,0.119,0.152,0.033,0.143,0.128,-0.015,0.183,0.104,-0.079,0.143
8 | ,0.151,0.672,0.521,0.119,0.128,0.009,0.103,0.192,0.089,0.159,0.288,0.129,0.086,0.327,0.241,0.191,0.168,-0.023,0.095,0.072,-0.023,0.103,0.193,0.09,0.142,0.136,-0.006,0.166,0.104,-0.062,0.143
9 | ,0.136,0.112,-0.024,0.087,0.184,0.097,0.134,0.128,-0.006,0.079
10 | ,0.071,0.177,0.106,0.095,0.16,0.065,0.103,0.151,0.048,0.135,0.273,0.138,0.102,0.622,0.52,0.312,0.257,-0.055,0.119,0.192,0.073,0.127,0.152,0.025,0.119,0.136,0.017,0.184,0.129,-0.055,0.11
11 | ,0.106,0.051,-0.055,0.071,0.192,0.121,0.119,0.152,0.033,0.095,0.12,0.025,0.112,0.08,-0.032,0.135
12 | ,0.09,0.083,-0.007,0.079,0.192,0.113,0.095,0.128,0.033,0.119,0.128,0.009,0.151,0.08,-0.071,0.143
13 | ,0.09,0.307,0.217,0.087,0.152,0.065,0.095,0.152,0.057,0.103,0.264,0.161,0.095,0.369,0.274,0.174,0.151,-0.023,0.103,0.136,0.033,0.087,0.136,0.049,0.127,0.168,0.041,0.167,0.112,-0.055,0.119
14 | ,0.167,0.072,-0.095,0.135,0.192,0.057,0.127,0.184,0.057,0.183,0.16,-0.023,0.167
15 | ,0.249,0.17,-0.079,0.086,1.671,1.585,0.103,0.192,0.089,0.095,0.4,0.305,0.176,0.088,-0.088,0.127,0.272,0.145,0.127,0.16,0.033,0.127,1.032,0.905,0.111,0.192,0.081,0.095,0.432,0.337,0.063,0.168,0.105,0.119,0.112,-0.007,0.215,0.152,-0.063,0.151,0.12,-0.031,0.111
16 | ,0.122,0.051,-0.071,0.079,0.184,0.105,0.103,0.072,-0.031,0.119,0.112,-0.007,0.127,0.12,-0.007,0.119
17 | ,0.135,1.248,1.113,0.134,0.168,0.034,0.119,0.175,0.056,0.152,0.385,0.233,0.103,0.504,0.401,0.239,0.192,-0.047,0.095,0.175,0.08,0.072,0.193,0.121,0.134,0.159,0.025,0.151,0.105,-0.046,0.135
18 | ,0.135,0.264,0.129,0.111,0.176,0.065,0.119,0.144,0.025,0.144,0.352,0.208,0.087,0.351,0.264,0.16,0.121,-0.039,0.103,0.144,0.041,0.127,0.144,0.017,0.127,0.104,-0.023,0.191,0.104,-0.087,0.151
19 | ,0.127,0.271,0.144,0.112,0.184,0.072,0.127,0.137,0.01,0.134,0.295,0.161,0.087,0.368,0.281,0.224,0.16,-0.064,0.119,0.16,0.041,0.127,0.16,0.033,0.135,0.16,0.025,0.176,0.08,-0.096,0.151
20 | ,0.118,0.151,0.033,0.063
21 | ,0.135,0.04,-0.095,0.095,0.2,0.105,0.143,0.096,-0.047,0.111
22 | ,0.191,0.088,-0.103,0.127,0.056,-0.071,0.151,0.016,-0.135,0.175
23 | ,0.183,0.096,-0.087,0.167,0.024,-0.143,0.222,0.072,-0.15,0.207,0.08,-0.127,0.142,0.056,-0.086,0.127,0.16,0.033,0.119
24 | ,0.119,0.008,-0.111,0.183,0.081,-0.102,0.118,0.04,-0.078,0.11,0.048,-0.062,0.094,0.007,-0.087,0.096
25 | ,0.061,0.046,-0.015,0.159,0.128,-0.031,0.071,0.017,-0.054,0.102,0.008,-0.094,0.103
26 | ,0.207,0.087,-0.12,0.159,0.152,-0.007,0.056,0.104,0.048,0.111,0.016,-0.095,0.103,0.048,-0.055,0.193,0.192,-0.001,0.087,0.008,-0.079,0.119,0.04,-0.079,0.135,0.152,0.017,0.119,0.024,-0.095,0.127,0.024,-0.103,0.119
27 | ,0.102,0.039,-0.063,0.175,0.104,-0.071,0.143,0.056,-0.087,0.193,0.048,-0.145,0.151,0.048,-0.103,0.127,0.002,-0.125,0.133,0.094,-0.039,0.127,0.003,-0.124,0.132,0.021,-0.111,0.456,0.136,-0.32,0.32,0.024,-0.296,0.296,0.048,-0.248,0.25,0.032,-0.218,0.297,0.024,-0.273,0.279,0.193,-0.086,0.102,0.007,-0.095,0.103,0.009,-0.094,0.102,0.007,-0.095,0.119,0.056,-0.063,0.092
28 | ,0.105,0.104,-0.001,0.055,0.144,0.089,0.095,0.088,-0.007,0.127,0.123,-0.004,0.156,0.101,-0.055,0.095
29 | ,0.11,0.072,-0.038,0.143,0.071,-0.072,0.111,0.008,-0.103,0.127,0.065,-0.062,0.134,0.023,-0.111,0.151
30 | ,0.118,1.136,1.018,0.206,0.312,0.106,0.166,0.344,0.178,0.158,1.064,0.906,0.166,0.591,0.425,0.447,0.305,-0.142,0.158,0.256,0.098,0.15,0.24,0.09,0.158,0.256,0.098,0.126,0.464,0.338,0.126
31 | ,0.321,0.218,-0.103,0.15,0.096,-0.054,0.078,0.176,0.098,0.094,0.128,0.034,0.118,0.096,-0.022,0.182,0.112,-0.07,0.134
32 | ,0.119,1.752,1.633,0.127,0.272,0.145,0.127,0.336,0.209,0.151,0.48,0.329,0.095,0.383,0.288,0.248,0.177,-0.071,0.143,0.224,0.081,0.135,0.328,0.193,0.135,0.383,0.248,0.16,0.305,0.145,0.111
33 | ,0.118,0.431,0.313,0.127,0.224,0.097,0.143,0.568,0.425,0.151,0.496,0.345,0.08,0.399,0.319,0.248,0.193,-0.055,0.143,0.209,0.066,0.142,0.302,0.16,0.184,0.249,0.065,0.255,0.216,-0.039,0.127
34 | ,0.127,0.32,0.193,0.119,0.192,0.073,0.127,0.384,0.257,0.143,0.608,0.465,0.087,0.367,0.28,0.256,0.169,-0.087,0.143,0.248,0.105,0.135,0.272,0.137,0.159,0.4,0.241,0.223,0.16,-0.063,0.119
35 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/KeystrokesInNano.csv:
--------------------------------------------------------------------------------
1 | User,H.period,DD.period.t,UD.period.t,H.t,DD.t.i,UD.t.i,H.i,DD.i.e,UD.i.e,H.e,DD.e.five,UD.e.five,H.five,DD.five.Shift.r,UD.five.Shift.r,H.Shift.r,DD.Shift.r.o,UD.Shift.r.o,H.o,DD.o.a,UD.o.a,H.a,DD.a.n,UD.a.n,H.n,DD.n.l,UD.n.l,H.l,DD.l.Return,UD.l.Return,H.Return
2 | ,98364252,195355498,96991246,94846410,128040471,33194061,126781139,143689154,16908015,127289375,248194139,120904764,86752948,288257822,201504874,206860600,159600911,-47259689,110930757,144004485,33073728,111045095,151977101,40932006,119007161,104013192,-14993969,182915948,95922766,-86993182,159244023
3 | ,97615442,50649359,-46966083,78854133,160261460,81407327,78726118,96088900,17362782,118604529,95756324,-22848205,126606363,79925617,-46680746,143165434
4 | ,126362004,87594385,-38767619,86619430,175888237,89268807,71369643,47928099,-23441544,142582283,136060649,-6521634,167053028,112183252,-54869776,134757469
5 | ,118911782,79831575,-39080207,110865646,208215100,97349454,142731668,135417934,-7313734,95245309,120673740,25428431,190915475,119842318,-71073157,150802186
6 | ,53313791,158758115,105444324,86655294,135516806,48861512,103617818,144528220,40910402,119082595,272264857,153182262,78752127,352118172,273366045,174569682,151874841,-22694841,102871931,127721967,24850036,119088616,135949698,16861082,126925959,192135207,65209248,166885414,104052448,-62832966,135087980
7 | ,107001922,219704946,112703024,103090694,160031519,56940825,111143347,168124242,56980895,111086969,288093694,177006725,86934713,287916551,200981838,207703125,191610176,-16092949,95394567,120196348,24801781,119179701,152195430,33015729,143066436,128060157,-15006279,182693979,103920708,-78773271,142933267
8 | ,150968462,671998382,521029920,118822244,127996617,9174373,102986009,192046122,89060113,158852330,288025356,129173026,86575652,327246701,240671049,191461379,168104982,-23356397,94970311,71926294,-23044017,102914842,192810919,89896077,142483402,135780887,-6702515,166758790,104381787,-62377003,142605902
9 | ,135380961,111617279,-23763682,86825164,184125569,97300405,134367241,127926577,-6440664,78923400
10 | ,71045595,176053885,105008290,95035306,160080685,65045379,102971743,151857694,48885951,135019731,272110446,137090715,102880171,622972371,520092200,311740036,257026369,-54713667,118964074,191981873,73017799,126964042,151806123,24842081,119141382,136148907,17007525,183095818,128101995,-54993823,110895485
11 | ,105924031,50920363,-55003668,71135991,192240838,121104847,118815811,152075877,33260066,94656194,119660946,25004752,111467592,80049885,-31417707,134880345
12 | ,89822681,82966121,-6856560,78685308,192216032,113530724,94833724,127815479,32981755,119198303,127694008,8495705,151322462,80447307,-70875155,142776592
13 | ,90588828,307626924,217038096,86949855,152091425,65141570,94689513,151852508,57162995,103077104,264119394,161042290,94805210,368401974,273596764,174378008,151510401,-22867607,103021366,136244383,33223017,86624224,135746460,49122236,127078708,168095380,41016672,166876938,112186384,-54690554,118681320
14 | ,167050041,72280955,-94769086,134736546,191956332,57219786,126934403,183940405,57006002,182955914,160054181,-22901733,166722721
15 | ,248153408,169185900,-78967508,86740879,1671894671,1585153792,102867272,192006148,89138876,94920883,399845266,304924383,175357961,88053968,-87303993,127147349,271981969,144834620,127018085,160179945,33161860,127004617,1031899226,904894609,110781105,191986003,81204898,95020353,432092859,337072506,62783281,167734631,104951350,118933887,112162185,-6771702,214995049,151924752,-63070297,150857938,120001694,-30856244,110839600
16 | ,122220218,51066552,-71153666,78889569,184025942,105136373,102724124,72081866,-30642258,118743422,111832287,-6911135,126660074,119930260,-6729814,118938146
17 | ,135005366,1247903184,1112897818,134550590,167989144,33438554,118977965,175831052,56853087,151157138,384330929,233173791,102864058,504082855,401218797,238840998,191742860,-47098138,95136871,175662477,80525606,71473656,192381657,120908001,134945373,159937353,24991980,150835704,104033596,-46802108,135016594
18 | ,135389254,264413063,129023809,110830348,175980168,65149820,118861664,143927720,25066056,143624319,352142481,208518162,86922118,350886260,263964142,159647693,120667738,-38979955,103332684,144123025,40790341,127083452,144124709,17041257,126937328,104126292,-22811036,190988852,103900267,-87088585,150958251
19 | ,126685330,271456610,144771280,111279482,184145516,72866034,126915031,136141154,9226123,134950777,295994742,161043965,86988785,367085173,280096388,223923874,160834248,-63089626,119056969,160016648,40959679,127025397,160005025,32979628,134967136,160056427,25089291,175088675,79731298,-95357377,151010942
20 | ,118340888,151284735,32943847,63005875
21 | ,135211297,39925413,-95285884,95472692,200231196,104758504,142930790,95906579,-47024211,111055471
22 | ,190713281,87773059,-102940222,126965039,56020951,-70944088,151018980,15825503,-135193477,175366640
23 | ,182419467,95633072,-86786395,167011613,23815230,-143196383,222896967,71945974,-150950993,207276894,80126358,-127150536,142503915,56120662,-86383253,126730981,159929221,33198240,118812087
24 | ,118980869,7727082,-111253787,182970266,80413799,-102556467,118402613,40114764,-78287849,110446716,47877553,-62569163,94823748,7794508,-87029240,95191739
25 | ,61562370,46729406,-14832964,158902512,128023291,-30879221,71005734,16082537,-54923197,102919487,8359530,-94559957,102625627
26 | ,206803162,87411974,-119391188,159044453,152245486,-6798967,55120780,104001224,48880444,110803683,15663456,-95140227,103026401,48082266,-54944135,192569839,192032377,-537462,87269165,7760570,-79508595,119499538,40391784,-79107754,134912579,151812327,16899748,119288068,24172718,-95115350,127126182,24078138,-103048044,119090683
27 | ,102685392,39720999,-62964393,174514390,103904799,-70609591,143096164,55746634,-87349530,192815156,48206833,-144608323,150616898,47703878,-102913020,127395613,2017051,-125378562,132956268,94281996,-38674272,127033034,2349408,-124683626,132738928,21350317,-111388611,455707603,136366113,-319341490,319531036,23805252,-295725784,295921554,48142551,-247779003,249431720,31489614,-217942106,297015703,24483209,-272532494,278890942,193020781,-85870161,101683603,6770172,-94913431,103021780,8901965,-94119815,102382589,7148429,-95234160,119190600,56266145,-62924455,92045735
28 | ,104413591,103859926,-553665,54583376,143957790,89374414,95021547,88003840,-7017707,126518483,122900986,-3617497,156129829,101043240,-55086589,95057441
29 | ,110524182,71770911,-38753271,143100542,71764183,-71336359,111094718,7832172,-103262546,127179947,64638305,-62541642,134672164,23476686,-111195478,151116352
30 | ,117562274,1135543865,1017981591,206091406,312064409,105973003,165995492,344146299,178150807,157793165,1063778833,905985668,166107143,591406835,425299692,446696181,304433194,-142262987,158166630,256223961,98057331,150057140,240042509,89985369,158029983,256014474,97984491,126187999,464043469,337855470,125794109
31 | ,320180435,217745084,-102435351,149937646,95829222,-54108424,78281490,176209998,97928508,93789270,127881084,34091814,117991303,96029627,-21961676,181905219,111573288,-70331931,134357615
32 | ,118988571,1752292340,1633303769,126529009,272026592,145497583,127072693,335838696,208766003,150701421,480309918,329608497,94421797,382388001,287966204,248117248,177418855,-70698393,142664198,223791606,81127408,134769579,327863787,193094208,134955767,383598558,248642791,159334129,304573360,145239231,110611811
33 | ,118472853,431562422,313089569,126629208,223807576,97178368,143171279,567906513,424735234,151413105,496242017,344828912,79534392,398948868,319414476,248020093,192644179,-55375914,143069960,209554622,66484662,141538320,302147077,160608757,183336674,248321114,64984440,254988948,216465582,-38523366,126555965
34 | ,126859115,319779967,192920852,119020905,191525309,72504404,127375724,384595494,257219770,142672860,607265713,464592853,87592356,367722698,280130342,255927400,168343479,-87583921,143446620,248338606,104891986,135290156,272387822,137097666,158559343,399638591,241079248,223032273,160231107,-62801166,118835687
35 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/artifacts/KeystrokeLoggingApplication_jar/KeystrokeLoggingApplication 2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/KeystrokeLoggingApplication/out/artifacts/KeystrokeLoggingApplication_jar/KeystrokeLoggingApplication 2.jar
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/artifacts/KeystrokeLoggingApplication_jar/KeystrokeLoggingApplication.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/KeystrokeLoggingApplication/out/artifacts/KeystrokeLoggingApplication_jar/KeystrokeLoggingApplication.jar
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/artifacts/KeystrokeLoggingApplication_jar/Keystrokes.csv:
--------------------------------------------------------------------------------
1 | User,H.period,DD.period.t,UD.period.t,H.t,DD.t.i,UD.t.i,H.i,DD.i.e,UD.i.e,H.e,DD.e.five,UD.e.five,H.five,DD.five.Shift.r,UD.five.Shift.r,H.Shift.r,DD.Shift.r.o,UD.Shift.r.o,H.o,DD.o.a,UD.o.a,H.a,DD.a.n,UD.a.n,H.n,DD.n.l,UD.n.l,H.l,DD.l.Return,UD.l.Return,H.Return
2 | ,0.143,0.288,0.145,0.12,0.28,0.16,0.143,0.273,0.13,0.159,0.351,0.192,0.159,0.495,0.336,0.296,0.234,-0.062,0.166,0.263,0.097,0.12,0.184,0.064,0.167,0.232,0.065,0.255,0.177,-0.078,0.166
3 | ,0.127,0.104,-0.023,0.047,0.152,0.105,0.103,0.112,0.009,0.127,0.112,-0.015,0.159,0.088,-0.071,0.135
4 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/artifacts/KeystrokeLoggingApplication_jar/KeystrokesInNano.csv:
--------------------------------------------------------------------------------
1 | User,H.period,DD.period.t,UD.period.t,H.t,DD.t.i,UD.t.i,H.i,DD.i.e,UD.i.e,H.e,DD.e.five,UD.e.five,H.five,DD.five.Shift.r,UD.five.Shift.r,H.Shift.r,DD.Shift.r.o,UD.Shift.r.o,H.o,DD.o.a,UD.o.a,H.a,DD.a.n,UD.a.n,H.n,DD.n.l,UD.n.l,H.l,DD.l.Return,UD.l.Return,H.Return
2 | ,143044088,288228719,145184631,119073713,279919128,160845415,143054321,272137570,129083249,158996936,351694553,192697617,158835092,495258528,336423436,295960510,233127777,-62832733,166924059,263774633,96850574,119239912,184127372,64887460,166695303,231976194,65280891,254884997,176346014,-78538983,166508773
3 | ,126658091,103814891,-22843200,46809072,151984704,105175632,103012364,112018227,9005863,126787449,111818598,-14968851,159208126,88009153,-71198973,135097032
4 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/KeyDataStore.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/KeyDataStore.class
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/KeyEventDemo$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/KeyEventDemo$1.class
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/KeyEventDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/KeyEventDemo.class
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: KeyEventDemo
3 |
4 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/TypedKeyObject.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/KeystrokeLoggingApplication/out/production/KeystrokeLoggingApplication/TypedKeyObject.class
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/src/KeyDataStore.java:
--------------------------------------------------------------------------------
1 | import java.util.ArrayList;
2 | import java.util.LinkedHashMap;
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | /**
7 | * Created by nikhilagrawal on 5/4/18.
8 | */
9 | public class KeyDataStore {
10 |
11 | LinkedHashMap store;
12 |
13 | KeyDataStore(){
14 |
15 | this.store = new LinkedHashMap();
16 | }
17 |
18 | public void initialize(){
19 | this.store = new LinkedHashMap();
20 | }
21 |
22 | public void storeTypedObject(Integer e, TypedKeyObject typedKeyObject){
23 | this.store.put(e,typedKeyObject);
24 | }
25 |
26 | public TypedKeyObject getKey(Integer e){
27 | if(this.store.size()>0){
28 | return this.store.get(e);
29 | }
30 | return null;
31 | }
32 |
33 | public void removeContainsOfMap(){
34 |
35 | this.store.clear();
36 | }
37 |
38 | /**
39 | * {“fields”:[“H.period”,“DD.period.t”,“UD.period.t”,“H.t”,“DD.t.i”,“UD.t.i”,“H.i”,“DD.i.e”,“UD.i.e”,“H.e”,
40 | * “DD.e.five”,“UD.e.five”,“H.five”,“DD.five.Shift.r”,“UD.five.Shift.r”,“H.Shift.r”,“DD.Shift.r.o”,“UD.Shift.r.o”
41 | * ,“H.o”,“DD.o.a”,“UD.o.a”,“H.a”,“DD.a.n”,“UD.a.n”,“H.n”,“DD.n.l”,“UD.n.l”,“H.l”,“DD.l.Return”,“UD.l.Return”,
42 | * “H.Return”],
43 | * “values”:[
44 | * [0.175,0.2034,0.0284,0.1227,0.1737,0.051,0.1301,0.146,0.0159,0.1159,0.3732,0.2573,
45 | * 0.1151,0.5741,0.459,0.155,0.1912,0.0362,0.1143,0.183,0.0687,0.1185,0.1196,0.0011,0.0895,
46 | * 0.2423,0.1528,0.1243,0.4899,0.3656,0.1206 ]
47 | * ]}
48 | */
49 | public List process(){
50 | /**
51 | * Key1 , Key2
52 | * Key1.HOLDTIME => Key1 releasetime - Key1 presstime.
53 | * Key1.DOWNDOWNTIME => KEY2 presstime - Key1 presstime
54 | * Key1.UPDOWNTIME => KEY2 presstime - key1 releasetime.
55 | */
56 | if(this.store.size()<2){
57 | System.out.print("number of keys pressed should be atleast 2"+this.store.toString());
58 | return null;
59 | }
60 | List strokes = new ArrayList();
61 |
62 | TypedKeyObject current = null;
63 | Long lastKeysHoldTime = null;
64 | for(Map.Entry entry: this.store.entrySet()){
65 | if(current == null){
66 | current = entry.getValue();
67 | }else{
68 | TypedKeyObject next = entry.getValue();
69 | Long key1HoldTime = current.releaseTime - current.pressTime;
70 | Long key1Key2DownTime = next.pressTime - current.pressTime;
71 | Long key1Key2UPDownTime = next.pressTime - current.releaseTime;
72 | strokes.add(key1HoldTime/1000.0);
73 | strokes.add(key1Key2DownTime/1000.0);
74 | strokes.add(key1Key2UPDownTime/1000.0);
75 |
76 |
77 |
78 | current = entry.getValue();
79 | lastKeysHoldTime = current.releaseTime-current.pressTime;
80 | }
81 | }
82 | strokes.add(lastKeysHoldTime/1000.0);
83 |
84 | return strokes;
85 | }
86 |
87 | public List processInNano(){
88 | /**
89 | * Key1 , Key2
90 | * Key1.HOLDTIME => Key1 releasetime - Key1 presstime.
91 | * Key1.DOWNDOWNTIME => KEY2 presstime - Key1 presstime
92 | * Key1.UPDOWNTIME => KEY2 presstime - key1 releasetime.
93 | */
94 | if(this.store.size()<2){
95 | System.out.print("number of keys pressed should be atleast 2"+this.store.toString());
96 | return null;
97 | }
98 | List strokes = new ArrayList();
99 |
100 | TypedKeyObject current = null;
101 | Long lastKeysHoldTime = null;
102 | for(Map.Entry entry: this.store.entrySet()){
103 | if(current == null){
104 | current = entry.getValue();
105 | }else{
106 | TypedKeyObject next = entry.getValue();
107 | Long key1HoldTime = current.releaseTimeinNano - current.pressTimeinNano;
108 | Long key1Key2DownTime = next.pressTimeinNano - current.pressTimeinNano;
109 | Long key1Key2UPDownTime = next.pressTimeinNano - current.releaseTimeinNano;
110 | strokes.add(key1HoldTime);
111 | strokes.add(key1Key2DownTime);
112 | strokes.add(key1Key2UPDownTime);
113 | current = entry.getValue();
114 | lastKeysHoldTime = current.releaseTimeinNano-current.pressTimeinNano;
115 | }
116 | }
117 | strokes.add(lastKeysHoldTime);
118 | return strokes;
119 | }
120 |
121 | }
122 |
123 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/src/KeyEventDemo.java:
--------------------------------------------------------------------------------
1 | import javax.swing.*;
2 | import java.awt.*;
3 | import java.awt.event.ActionEvent;
4 | import java.awt.event.ActionListener;
5 | import java.awt.event.KeyEvent;
6 | import java.awt.event.KeyListener;
7 | import java.io.*;
8 | import java.util.List;
9 |
10 |
11 | public class KeyEventDemo extends JFrame
12 | implements KeyListener,
13 | ActionListener
14 | {
15 | private static final String COMMA_DELIMITER = ",";
16 | private static final String NEW_LINE_SEPARATOR = "\n";
17 | private static final String FILE_HEADER = "User,H.period,DD.period.t,UD.period.t,H.t,DD.t.i,UD.t.i,H.i,DD.i.e,UD.i.e," +
18 | "H.e,DD.e.five,UD.e.five,H.five,DD.five.Shift.r,UD.five.Shift.r,H.Shift.r,DD.Shift.r.o,UD.Shift.r.o,H.o," +
19 | "DD.o.a,UD.o.a,H.a,DD.a.n,UD.a.n,H.n,DD.n.l,UD.n.l,H.l,DD.l.Return,UD.l.Return,H.Return";
20 | private static boolean flag = true;
21 | JTextArea displayArea;
22 | JTextField typingArea;
23 |
24 | static final String newline = System.getProperty("line.separator");
25 |
26 | public static void main(String[] args) {
27 |
28 | /* Use an appropriate Look and Feel */
29 | try {
30 | UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
31 | } catch (UnsupportedLookAndFeelException ex) {
32 | ex.printStackTrace();
33 | } catch (IllegalAccessException ex) {
34 | ex.printStackTrace();
35 | } catch (InstantiationException ex) {
36 | ex.printStackTrace();
37 | } catch (ClassNotFoundException ex) {
38 | ex.printStackTrace();
39 | }
40 | /* Turn off metal's use of bold fonts */
41 | UIManager.put("swing.boldMetal", Boolean.FALSE);
42 |
43 | //Schedule a job for event dispatch thread:
44 | //creating and showing this application's GUI.
45 | SwingUtilities.invokeLater(new Runnable() {
46 | public void run() {
47 | createAndShowGUI();
48 | }
49 | });
50 | }
51 |
52 | /**
53 | * Create the GUI and show it. For thread safety,
54 | * this method should be invoked from the
55 | * event-dispatching thread.
56 | */
57 | private static void createAndShowGUI() {
58 | //Create and set up the window.
59 | KeyEventDemo frame = new KeyEventDemo("Keystroke Logging Application");
60 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
61 |
62 | //Set up the content pane.
63 | frame.addComponentsToPane();
64 |
65 |
66 | //Display the window.
67 | frame.pack();
68 | frame.setVisible(true);
69 | }
70 |
71 | private void addComponentsToPane() {
72 |
73 | JButton button = new JButton("Clear");
74 | button.addActionListener(this);
75 |
76 |
77 |
78 | typingArea = new JTextField(20);
79 | typingArea.addKeyListener(this);
80 | displayArea = new JTextArea();
81 | displayArea.setEditable(false);
82 | JScrollPane scrollPane = new JScrollPane(displayArea);
83 | scrollPane.setPreferredSize(new Dimension(500, 250));
84 |
85 | getContentPane().add(typingArea, BorderLayout.PAGE_START);
86 | getContentPane().add(scrollPane, BorderLayout.CENTER);
87 | getContentPane().add(button, BorderLayout.PAGE_END);
88 | }
89 |
90 | KeyDataStore store;
91 | int pressIndex = 0;
92 | int releaseIndex = 0;
93 |
94 | public KeyEventDemo(String name) {
95 | super(name);
96 | this.store = new KeyDataStore();
97 | }
98 |
99 | /** Handle the key typed event from the text field. */
100 | public void keyTyped(KeyEvent e) {
101 |
102 |
103 | }
104 |
105 | /** Handle the key pressed event from the text field. */
106 | public void keyPressed(KeyEvent e) {
107 | displayArea.setText("");
108 |
109 | if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE){
110 | typingArea.setText("");
111 | this.store.removeContainsOfMap();
112 | releaseIndex=0;
113 | pressIndex = 0;
114 | }
115 |
116 |
117 | if(e.getKeyCode() == KeyEvent.VK_ENTER){
118 |
119 | String str = typingArea.getText();
120 | System.out.println(str);
121 | //if( str.equals(".tie5Roanl")){
122 | List keyStoreParams = this.store.process();
123 | List keyStoreParamsInNano = this.store.processInNano();
124 | System.out.println(keyStoreParamsInNano.toString());
125 | System.out.println(keyStoreParams.toString());
126 | System.out.println(keyStoreParams.size());
127 | this.store.initialize();
128 | pressIndex = 0;
129 | typingArea.setText("");
130 | generateCsv(keyStoreParams,"");
131 | generateCsvInNano(keyStoreParamsInNano,"");
132 | return;
133 | //
134 | // //}else{
135 | // displayArea.setText(str);
136 | // displayArea.setText("Please insert correct password");
137 | // typingArea.setText("");
138 | // this.store.removeContainsOfMap();
139 | // releaseIndex=0;
140 | // pressIndex = 0;
141 | // return;
142 | //
143 | // }
144 |
145 |
146 | }
147 |
148 | TypedKeyObject typedKeyObject = new TypedKeyObject();
149 | typedKeyObject.pressTime = System.currentTimeMillis();
150 | typedKeyObject.pressTimeinNano = System.nanoTime();
151 | this.store.storeTypedObject(pressIndex,typedKeyObject);
152 | pressIndex++;
153 | }
154 |
155 | /** Handle the key released event from the text field. */
156 | public void keyReleased(KeyEvent e) {
157 | //displayInfo(e, "KEY RELEASED: ");
158 | if(e.getKeyCode() == KeyEvent.VK_ENTER){
159 | releaseIndex = 0;
160 | return;
161 | }
162 | if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE){
163 | typingArea.setText("");
164 | this.store.removeContainsOfMap();
165 | pressIndex = 0;
166 | releaseIndex=0;
167 | return;
168 | }
169 | if(this.store.getKey(releaseIndex)!=null) {
170 | this.store.getKey(releaseIndex).releaseTime = System.currentTimeMillis();
171 | this.store.getKey(releaseIndex).releaseTimeinNano = System.nanoTime();
172 |
173 | releaseIndex++;
174 | }
175 | }
176 |
177 | /**
178 | * Handle the button click.
179 | */
180 | public void actionPerformed(ActionEvent e) {
181 | //Clear the text components.
182 | displayArea.setText("");
183 | typingArea.setText("");
184 | //Return the focus to the typing area.
185 | typingArea.requestFocusInWindow();
186 | }
187 |
188 |
189 | /**
190 | * This function create csv which stores your keystroke eachtime after
191 | * you enter valid password.
192 | * Function is used data collection. This data will be used for
193 | * training and tesing machine learning model.
194 | * @param keyStoreParams : list of keyhold,kyup,keydown timings
195 | */
196 | public void generateCsv(List keyStoreParams,String userName) {
197 |
198 | FileWriter fileWriter = null;
199 | try {
200 |
201 | String filename = userName+"Keystrokes.csv";
202 | File file = new File(filename);
203 |
204 | // if file doesnt exists, then create it
205 | if (!file.exists()) {
206 | file.createNewFile();
207 | }
208 |
209 | fileWriter = new FileWriter(file.getAbsoluteFile(), true);
210 |
211 |
212 | BufferedReader reader = new BufferedReader(new FileReader(filename));
213 |
214 | if (reader.readLine() == null) {
215 | fileWriter.append(FILE_HEADER.toString());
216 | fileWriter.append(NEW_LINE_SEPARATOR);
217 | }
218 | fileWriter.append(userName);
219 | fileWriter.append(COMMA_DELIMITER);
220 | for (int j = 0; j < keyStoreParams.size() - 1; j++) {
221 | fileWriter.append("" + keyStoreParams.get(j));
222 | fileWriter.append(COMMA_DELIMITER);
223 | }
224 | fileWriter.append("" + keyStoreParams.get(keyStoreParams.size() - 1));
225 |
226 | fileWriter.append(NEW_LINE_SEPARATOR);
227 | System.out.println("CSV file was created successfully !!!");
228 |
229 |
230 | typingArea.setText("");
231 | //Return the focus to the typing area.
232 | displayArea.setText("Typing pattern is: \n" + keyStoreParams.toString());
233 | typingArea.requestFocusInWindow();
234 |
235 | } catch (Exception e2) {
236 | System.out.println("Error in CsvFileWriter !!!");
237 | e2.printStackTrace();
238 | } finally {
239 |
240 | try {
241 | fileWriter.flush();
242 | } catch (IOException e) {
243 | e.printStackTrace();
244 | }
245 | try {
246 | fileWriter.close();
247 | } catch (IOException e) {
248 | e.printStackTrace();
249 | }
250 |
251 | }
252 | }
253 |
254 | public void generateCsvInNano(List keyStoreParams,String userName) {
255 |
256 | FileWriter fileWriter = null;
257 | try {
258 | String fileName = userName+"KeystrokesInNano.csv";
259 | //fileWriter = null;
260 | File file = new File(fileName);
261 |
262 | // if file doesnt exists, then create it
263 | if (!file.exists()) {
264 | file.createNewFile();
265 | }
266 |
267 | fileWriter = new FileWriter(file.getAbsoluteFile(), true);
268 |
269 |
270 | BufferedReader reader = new BufferedReader(new FileReader(fileName));
271 |
272 | if (reader.readLine() == null) {
273 | fileWriter.append(FILE_HEADER.toString());
274 | fileWriter.append(NEW_LINE_SEPARATOR);
275 | }
276 |
277 |
278 |
279 | fileWriter.append(userName);
280 | fileWriter.append(COMMA_DELIMITER);
281 | for (int j = 0; j < keyStoreParams.size() - 1; j++) {
282 | fileWriter.append("" + keyStoreParams.get(j));
283 | fileWriter.append(COMMA_DELIMITER);
284 | }
285 | fileWriter.append("" + keyStoreParams.get(keyStoreParams.size() - 1));
286 |
287 | fileWriter.append(NEW_LINE_SEPARATOR);
288 | System.out.println("CSV file was created successfully !!!");
289 |
290 | typingArea.setText("");
291 | //Return the focus to the typing area.
292 | // displayArea.setText(keyStoreParams.toString());
293 | typingArea.requestFocusInWindow();
294 |
295 | } catch (Exception e2) {
296 | System.out.println("Error in CsvFileWriter !!!");
297 | e2.printStackTrace();
298 | } finally {
299 |
300 | try {
301 | fileWriter.flush();
302 | } catch (IOException e) {
303 | e.printStackTrace();
304 | }
305 | try {
306 | fileWriter.close();
307 | } catch (IOException e) {
308 | e.printStackTrace();
309 | }
310 |
311 | }
312 | }
313 | }
314 |
315 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/src/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: KeyEventDemo
3 |
4 |
--------------------------------------------------------------------------------
/KeystrokeLoggingApplication/src/TypedKeyObject.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by nikhilagrawal on 5/4/18.
3 | */
4 | public class TypedKeyObject {
5 | int id;
6 | Character c;
7 | Long pressTime;
8 | Long releaseTime;
9 | Long releaseTimeinNano;
10 | Long pressTimeinNano;
11 |
12 | public TypedKeyObject(){
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # User Authentication Using Keystroke Dynamics
2 |
3 | The unique typing patterns of users can be used as a signature to identify genuine users from imposters. Keystroke signature fuses the simplicity of passwords with increased reliability from biometrics. Unlike other biometrics like IRIS, face, fingerprints etc which need special hardware infrastructure, keystroke biometrics are economical to implement and can be easily integrated into the existing computer security systems. They help augment the existing security infrastructure by being part of a multilevel authentication system. Using Machine learning algorithms, a high accuracy rate in detecting imposters has been demonstrated in this project. The machine learning model is trained with the typing patterns of the subjects. Then it is provided with test data with patterns from the subject as well as from imposters posing as the subject. The model demonstrates the ability to discern genuine users from imposters based on the test pattern’s similarity to the trained model for the subject.
4 |
5 | ### Data Collection
6 | **There was't any dataset present of keystroke patterns so build standalone desktop application to collect keystrokes from users. The create a typing pattern used calculated 3 different type of timings
7 | for each key pressed.**
8 | * **Hold time** – time between press and release of a key.
9 | * **Keydown-Keydown time** – time between the pressing of consecutive keys.
10 | * **Keyup-Keydown time** – time between the release of one key and the press of next key.
11 |
12 |
13 |
14 |
15 | **Follwed above procedure and collected data from 15 different users**
16 | ### Feature selection
17 | For the password typed for each key pressed measured hold time, Keydown-Keydown time,Keyup-Keydown time in milliseconds and this were considered as features.
18 |
19 |
20 |
21 | ### Training Machine Learning Models.
22 | As the problem is classification of user whether the user is genuine or imposter, supervised learning algorithms like logistic regression, support vector machine and K-nearest-neighbour were used.Used sklearn libraries for training the models.
23 |
24 | ### Test & evaluate the ML Model
25 | * Train Test Split, where the dataset is divided into two different datasets, training set and testing set.Train the data with training set and test the data on testing set and evaluate the accuracy of the model
26 | * Cross Validation: Split dataset into K equal partitions(folds), Use partition 1 as testing set and remaining K-1 partitions as training set and calculate accuracy. Repeat the process K number of times and use average of all the accuracies to evaluate model performance.
27 |
28 | ### Results
29 |
30 |
31 |
32 |
33 | ### References
34 | * https://ieeexplore.ieee.org/abstract/document/5270346
35 |
36 |
--------------------------------------------------------------------------------
/User Authentication Application/.idea/artifacts/Keystroke_App_50_50_6_2_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/out/artifacts/Keystroke_App_50_50_6_2_2_jar
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/User Authentication Application/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/User Authentication Application/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/User Authentication Application/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/User Authentication Application/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 | 1525828636707
431 |
432 |
433 | 1525828636707
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 | Keystroke App 50-50.6-2-2:jar
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 | No facets are configured
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 | 1.8
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 | Keystroke App 50-50.6-2-2
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
--------------------------------------------------------------------------------
/User Authentication Application/Keystroke App 50-50.6-2-2.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/User Authentication Application/lib/json-simple-1.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/lib/json-simple-1.1.1.jar
--------------------------------------------------------------------------------
/User Authentication Application/out/artifacts/Keystroke_App_50_50_6_2_2_jar/Keystroke App 50-50.6-2-2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/out/artifacts/Keystroke_App_50_50_6_2_2_jar/Keystroke App 50-50.6-2-2.jar
--------------------------------------------------------------------------------
/User Authentication Application/out/artifacts/Keystroke_App_50_50_6_2_2_jar/UserAuthenticationApplication.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/out/artifacts/Keystroke_App_50_50_6_2_2_jar/UserAuthenticationApplication.jar
--------------------------------------------------------------------------------
/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyDataStore.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyDataStore.class
--------------------------------------------------------------------------------
/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyEventDemo$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyEventDemo$1.class
--------------------------------------------------------------------------------
/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyEventDemo$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyEventDemo$2.class
--------------------------------------------------------------------------------
/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyEventDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/KeyEventDemo.class
--------------------------------------------------------------------------------
/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: KeyEventDemo
3 |
4 |
--------------------------------------------------------------------------------
/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/TypedKeyObject.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/User Authentication Application/out/production/Keystroke App 50-50.6-2-2/TypedKeyObject.class
--------------------------------------------------------------------------------
/User Authentication Application/src/KeyDataStore.java:
--------------------------------------------------------------------------------
1 | import java.util.ArrayList;
2 | import java.util.LinkedHashMap;
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | /**
7 | * Created by nikhilagrawal on 5/4/18.
8 | */
9 | public class KeyDataStore {
10 |
11 | LinkedHashMap store;
12 |
13 | KeyDataStore(){
14 | this.store = new LinkedHashMap();
15 | }
16 |
17 | public void initialize(){
18 | this.store = new LinkedHashMap();
19 | }
20 |
21 | public void storeTypedObject(Integer e,TypedKeyObject typedKeyObject){
22 | this.store.put(e,typedKeyObject);
23 | }
24 |
25 | public TypedKeyObject getKey(Integer e){
26 | if(this.store.size()>0){
27 | return this.store.get(e);
28 | }
29 | return null;
30 | }
31 |
32 | public void removeContainsOfMap(){
33 |
34 | this.store.clear();
35 | }
36 |
37 | /**
38 | * {“fields”:[“H.period”,“DD.period.t”,“UD.period.t”,“H.t”,“DD.t.i”,“UD.t.i”,“H.i”,“DD.i.e”,“UD.i.e”,“H.e”,
39 | * “DD.e.five”,“UD.e.five”,“H.five”,“DD.five.Shift.r”,“UD.five.Shift.r”,“H.Shift.r”,“DD.Shift.r.o”,“UD.Shift.r.o”
40 | * ,“H.o”,“DD.o.a”,“UD.o.a”,“H.a”,“DD.a.n”,“UD.a.n”,“H.n”,“DD.n.l”,“UD.n.l”,“H.l”,“DD.l.Return”,“UD.l.Return”,
41 | * “H.Return”],
42 | * “values”:[
43 | * [0.175,0.2034,0.0284,0.1227,0.1737,0.051,0.1301,0.146,0.0159,0.1159,0.3732,0.2573,
44 | * 0.1151,0.5741,0.459,0.155,0.1912,0.0362,0.1143,0.183,0.0687,0.1185,0.1196,0.0011,0.0895,
45 | * 0.2423,0.1528,0.1243,0.4899,0.3656,0.1206 ]
46 | * ]}
47 | */
48 | public List process(){
49 | /**
50 | * Key1 , Key2
51 | * Key1.HOLDTIME => Key1 releasetime - Key1 presstime.
52 | * Key1.DOWNDOWNTIME => KEY2 presstime - Key1 presstime
53 | * Key1.UPDOWNTIME => KEY2 presstime - key1 releasetime.
54 | */
55 | if(this.store.size()<2){
56 | System.out.print("number of keys pressed should be atleast 2"+this.store.toString());
57 | return null;
58 | }
59 | List strokes = new ArrayList();
60 |
61 | TypedKeyObject current = null;
62 | Long lastKeysHoldTime = null;
63 | for(Map.Entry entry: this.store.entrySet()){
64 | if(current == null){
65 | current = entry.getValue();
66 | }else{
67 | TypedKeyObject next = entry.getValue();
68 | Long key1HoldTime = current.releaseTime - current.pressTime;
69 | Long key1Key2DownTime = next.pressTime - current.pressTime;
70 | Long key1Key2UPDownTime = next.pressTime - current.releaseTime;
71 | strokes.add(key1HoldTime/1000.0);
72 | strokes.add(key1Key2DownTime/1000.0);
73 | strokes.add(key1Key2UPDownTime/1000.0);
74 |
75 |
76 |
77 | current = entry.getValue();
78 | lastKeysHoldTime = current.releaseTime-current.pressTime;
79 | }
80 | }
81 | strokes.add(lastKeysHoldTime/1000.0);
82 |
83 | return strokes;
84 | }
85 |
86 | public List processInNano(){
87 | /**
88 | * Key1 , Key2
89 | * Key1.HOLDTIME => Key1 releasetime - Key1 presstime.
90 | * Key1.DOWNDOWNTIME => KEY2 presstime - Key1 presstime
91 | * Key1.UPDOWNTIME => KEY2 presstime - key1 releasetime.
92 | */
93 | if(this.store.size()<2){
94 | System.out.print("number of keys pressed should be atleast 2"+this.store.toString());
95 | return null;
96 | }
97 | List strokes = new ArrayList();
98 |
99 | TypedKeyObject current = null;
100 | Long lastKeysHoldTime = null;
101 | for(Map.Entry entry: this.store.entrySet()){
102 | if(current == null){
103 | current = entry.getValue();
104 | }else{
105 | TypedKeyObject next = entry.getValue();
106 | Long key1HoldTime = current.releaseTimeinNano - current.pressTimeinNano;
107 | Long key1Key2DownTime = next.pressTimeinNano - current.pressTimeinNano;
108 | Long key1Key2UPDownTime = next.pressTimeinNano - current.releaseTimeinNano;
109 | strokes.add(key1HoldTime);
110 | strokes.add(key1Key2DownTime);
111 | strokes.add(key1Key2UPDownTime);
112 | current = entry.getValue();
113 | lastKeysHoldTime = current.releaseTimeinNano-current.pressTimeinNano;
114 | }
115 | }
116 | strokes.add(lastKeysHoldTime);
117 | return strokes;
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/User Authentication Application/src/KeyEventDemo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * IBM Machine Learning Service :predictive-modeling-km
3 | * IBM Spark instance :
4 | * Project Name : Keystroke Dynamics 2
5 | * Model name: Model
6 | * Creation Date: 8th May
7 | * Dataset : final_data50-50woun
8 | * Train-Test-Hold Split : Train: 60%, Test: 20%, Holdout: 20%
9 | *
10 | */
11 |
12 | import org.json.simple.JSONArray;
13 | import org.json.simple.JSONObject;
14 | import org.json.simple.parser.*;
15 | import javax.swing.*;
16 | import java.awt.*;
17 | import java.awt.event.ActionEvent;
18 | import java.awt.event.ActionListener;
19 | import java.awt.event.KeyEvent;
20 | import java.awt.event.KeyListener;
21 | import java.io.*;
22 | import java.net.HttpURLConnection;
23 | import java.net.URL;
24 | import java.nio.charset.StandardCharsets;
25 | import java.util.Base64;
26 | import java.util.HashMap;
27 | import java.util.List;
28 | import java.util.Map;
29 |
30 |
31 | public class KeyEventDemo extends JFrame
32 | implements KeyListener,
33 | ActionListener
34 | {
35 | private static final String COMMA_DELIMITER = ",";
36 | private static final String NEW_LINE_SEPARATOR = "\n";
37 | private static final String FILE_HEADER = "User,H.period,DD.period.t,UD.period.t,H.t,DD.t.i,UD.t.i,H.i,DD.i.e,UD.i.e," +
38 | "H.e,DD.e.five,UD.e.five,H.five,DD.five.Shift.r,UD.five.Shift.r,H.Shift.r,DD.Shift.r.o,UD.Shift.r.o,H.o," +
39 | "DD.o.a,UD.o.a,H.a,DD.a.n,UD.a.n,H.n,DD.n.l,UD.n.l,H.l,DD.l.Return,UD.l.Return,H.Return";
40 | private String URL = "https://us-south.ml.cloud.ibm.com";
41 | private String USERNAME = "2c383eb6-e1d4-4230-b4ed-264227181fcf";
42 | private String PASSWORD = "15311162-bab9-4e32-aa1c-b56371397b71";
43 | private String SCORING_URL = "https://us-south.ml.cloud.ibm.com/v3/wml_instances/0b42d0ff-3ee9-4bae-a9c3-8dbf9e5fa12b/deployments/45893a83-96ec-4bcc-9301-4816b545751b/online";
44 |
45 | JTextArea displayArea;
46 | JTextField typingArea;
47 |
48 |
49 | static final String newline = System.getProperty("line.separator");
50 |
51 | public static void main(String[] args) {
52 |
53 | /* Use an appropriate Look and Feel */
54 | try {
55 | UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
56 | } catch (UnsupportedLookAndFeelException ex) {
57 | ex.printStackTrace();
58 | } catch (IllegalAccessException ex) {
59 | ex.printStackTrace();
60 | } catch (InstantiationException ex) {
61 | ex.printStackTrace();
62 | } catch (ClassNotFoundException ex) {
63 | ex.printStackTrace();
64 | }
65 | /* Turn off metal's use of bold fonts */
66 | UIManager.put("swing.boldMetal", Boolean.FALSE);
67 |
68 | //Schedule a job for event dispatch thread:
69 | //creating and showing this application's GUI.
70 | SwingUtilities.invokeLater(new Runnable() {
71 | public void run() {
72 | createAndShowGUI();
73 | }
74 | });
75 | }
76 |
77 | /**
78 | * Create the GUI and show it. For thread safety,
79 | * this method should be invoked from the
80 | * event-dispatching thread.
81 | */
82 | private static void createAndShowGUI() {
83 | //Create and set up the window.
84 | KeyEventDemo frame = new KeyEventDemo("Keystroke Anomaly Detector");
85 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
86 |
87 | //Set up the content pane.
88 | frame.addComponentsToPane();
89 |
90 | //Display the window.
91 | frame.pack();
92 | frame.setVisible(true);
93 | }
94 |
95 | private void addComponentsToPane() {
96 |
97 | JButton button = new JButton("Clear");
98 | button.addActionListener(this);
99 | typingArea = new JTextField(20);
100 | typingArea.addKeyListener(this);
101 | displayArea = new JTextArea();
102 | displayArea.setEditable(false);
103 | typingArea.setToolTipText("Please enter the Password");
104 | displayArea.setText("Please enter password: .tie5Roanl");
105 | typingArea.setPreferredSize(new Dimension(500, 20));
106 | JScrollPane scrollPane = new JScrollPane(displayArea);
107 | scrollPane.setPreferredSize(new Dimension(500, 225));
108 | getContentPane().add(typingArea, BorderLayout.PAGE_START);
109 | getContentPane().add(scrollPane, BorderLayout.CENTER);
110 | getContentPane().add(button, BorderLayout.PAGE_END);
111 | }
112 |
113 | KeyDataStore store;
114 | int pressIndex = 0;
115 | int releaseIndex = 0;
116 |
117 | public KeyEventDemo(String name) {
118 | super(name);
119 | this.store = new KeyDataStore();
120 | }
121 |
122 | /** Handle the key typed event from the text field. */
123 | public void keyTyped(KeyEvent e) {
124 |
125 |
126 | }
127 |
128 | /** Handle the key pressed event from the text field. */
129 | public void keyPressed(KeyEvent e) {
130 |
131 | // if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE){
132 | // typingArea.setText("");
133 | // this.store.removeContainsOfMap();
134 | // releaseIndex=0;
135 | // pressIndex = 0;
136 | // }
137 |
138 |
139 | if(e.getKeyCode() == KeyEvent.VK_ENTER){
140 | displayArea.setText("");
141 | String str = typingArea.getText();
142 | System.out.println(str);
143 |
144 |
145 | if( str.equals(".tie5Roanl")){
146 | List keyStoreParams = this.store.process();
147 | List keyStoreParamsInNano = this.store.processInNano();
148 | System.out.println(keyStoreParamsInNano.toString());
149 |
150 | System.out.println(keyStoreParams.toString());
151 | System.out.println(keyStoreParams.size());
152 | this.store.initialize();
153 | pressIndex = 0;
154 | typingArea.setText("");
155 |
156 | //generateCsv(keyStoreParams,"Nikhil");
157 | //generateCsvInNano(keyStoreParamsInNano,"Nikhil");
158 |
159 | sendRequest(keyStoreParams,URL,SCORING_URL,USERNAME,PASSWORD);
160 | return;
161 |
162 | }else{
163 | displayArea.setText(str);
164 | displayArea.setText("Please insert correct password");
165 | typingArea.setText("");
166 | this.store.removeContainsOfMap();
167 | releaseIndex=0;
168 | pressIndex = 0;
169 | return;
170 |
171 | }
172 |
173 |
174 | }
175 |
176 | // if(e.getKeyCode() != KeyEvent.VK_SHIFT){
177 | TypedKeyObject typedKeyObject = new TypedKeyObject();
178 | typedKeyObject.pressTime = System.currentTimeMillis();
179 | typedKeyObject.pressTimeinNano = System.nanoTime();
180 | this.store.storeTypedObject(pressIndex,typedKeyObject);
181 | pressIndex++;
182 | //}
183 |
184 |
185 | }
186 |
187 | /** Handle the key released event from the text field. */
188 | public void keyReleased(KeyEvent e) {
189 | if(e.getKeyCode() == KeyEvent.VK_ENTER){
190 | releaseIndex = 0;
191 | return;
192 | }
193 | // if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE){
194 | // typingArea.setText("");
195 | // this.store.removeContainsOfMap();
196 | // pressIndex = 0;
197 | // releaseIndex=0;
198 | // return;
199 | // }
200 | if(this.store.getKey(releaseIndex)!=null) {
201 | this.store.getKey(releaseIndex).releaseTime = System.currentTimeMillis();
202 | this.store.getKey(releaseIndex).releaseTimeinNano = System.nanoTime();
203 |
204 | releaseIndex++;
205 | }
206 | }
207 |
208 | /**
209 | * Handle the button click.
210 | */
211 | public void actionPerformed(ActionEvent e) {
212 | //Clear the text components.
213 | displayArea.setText("");
214 | typingArea.setText("");
215 | //Return the focus to the typing area.
216 | typingArea.requestFocusInWindow();
217 | }
218 |
219 | /**
220 | * This function create csv which stores your keystroke eachtime after
221 | * you enter valid password.
222 | * Function is used data collection. This data will be used for
223 | * training and tesing machine learning model.
224 | * @param keyStoreParams : list of keyhold,kyup,keydown timings
225 | */
226 | public void generateCsv(List keyStoreParams,String userName) {
227 |
228 | FileWriter fileWriter = null;
229 | try {
230 |
231 | String filename = userName+"Keystrokes.csv";
232 | File file = new File(filename);
233 |
234 | // if file doesnt exists, then create it
235 | if (!file.exists()) {
236 | file.createNewFile();
237 | }
238 |
239 | fileWriter = new FileWriter(file.getAbsoluteFile(), true);
240 |
241 |
242 | BufferedReader reader = new BufferedReader(new FileReader(filename));
243 |
244 | if (reader.readLine() == null) {
245 | fileWriter.append(FILE_HEADER.toString());
246 | fileWriter.append(NEW_LINE_SEPARATOR);
247 | }
248 | fileWriter.append(userName);
249 | fileWriter.append(COMMA_DELIMITER);
250 | for (int j = 0; j < keyStoreParams.size() - 1; j++) {
251 | fileWriter.append("" + keyStoreParams.get(j));
252 | fileWriter.append(COMMA_DELIMITER);
253 | }
254 | fileWriter.append("" + keyStoreParams.get(keyStoreParams.size() - 1));
255 |
256 | fileWriter.append(NEW_LINE_SEPARATOR);
257 | System.out.println("CSV file was created successfully !!!");
258 |
259 | typingArea.setText("");
260 | //Return the focus to the typing area.
261 | typingArea.requestFocusInWindow();
262 |
263 | } catch (Exception e2) {
264 | System.out.println("Error in CsvFileWriter !!!");
265 | e2.printStackTrace();
266 | } finally {
267 |
268 | try {
269 | fileWriter.flush();
270 | } catch (IOException e) {
271 | e.printStackTrace();
272 | }
273 | try {
274 | fileWriter.close();
275 | } catch (IOException e) {
276 | e.printStackTrace();
277 | }
278 |
279 | }
280 | }
281 |
282 | public void generateCsvInNano(List keyStoreParams,String userName) {
283 |
284 | FileWriter fileWriter = null;
285 | try {
286 | String fileName = userName+"KeystrokesInNano.csv";
287 | File file = new File(fileName);
288 |
289 | // if file doesnt exists, then create it
290 | if (!file.exists()) {
291 | file.createNewFile();
292 | }
293 |
294 | fileWriter = new FileWriter(file.getAbsoluteFile(), true);
295 | BufferedReader reader = new BufferedReader(new FileReader(fileName));
296 | if (reader.readLine() == null) {
297 | fileWriter.append(FILE_HEADER.toString());
298 | fileWriter.append(NEW_LINE_SEPARATOR);
299 | }
300 |
301 | fileWriter.append(userName);
302 | fileWriter.append(COMMA_DELIMITER);
303 |
304 | for (int j = 0; j < keyStoreParams.size() - 1; j++) {
305 | fileWriter.append("" + keyStoreParams.get(j));
306 | fileWriter.append(COMMA_DELIMITER);
307 | }
308 |
309 | fileWriter.append("" + keyStoreParams.get(keyStoreParams.size() - 1));
310 | fileWriter.append(NEW_LINE_SEPARATOR);
311 | System.out.println("CSV file was created successfully !!!");
312 | typingArea.setText("");
313 | //Return the focus to the typing area.
314 | typingArea.requestFocusInWindow();
315 |
316 | } catch (Exception e2) {
317 | System.out.println("Error in CsvFileWriter !!!");
318 | e2.printStackTrace();
319 | } finally {
320 |
321 | try {
322 | fileWriter.flush();
323 | } catch (IOException e) {
324 | e.printStackTrace();
325 | }
326 | try {
327 | fileWriter.close();
328 | } catch (IOException e) {
329 | e.printStackTrace();
330 | }
331 |
332 | }
333 | }
334 |
335 |
336 | /**
337 | *
338 | * @param list : list of keystrokes to be sent
339 | */
340 | public void sendRequest(List list,String url,String scoringurl,String username,String password){
341 |
342 | JSONObject ob = new JSONObject();
343 | JSONArray arrayOfFields = new JSONArray();
344 | arrayOfFields.add("H.period");
345 | arrayOfFields.add("DD.period.t");
346 | arrayOfFields.add("UD.period.t");
347 | arrayOfFields.add("H.t");
348 | arrayOfFields.add("DD.t.i");
349 | arrayOfFields.add("UD.t.i");
350 | arrayOfFields.add("H.i");
351 | arrayOfFields.add("DD.i.e");
352 | arrayOfFields.add("UD.i.e");
353 | arrayOfFields.add("H.e");
354 | arrayOfFields.add("DD.e.five");
355 | arrayOfFields.add("UD.e.five");
356 | arrayOfFields.add("H.five");
357 | arrayOfFields.add("DD.five.Shift.r");
358 | arrayOfFields.add("UD.five.Shift.r");
359 | arrayOfFields.add("H.Shift.r");
360 | arrayOfFields.add("DD.Shift.r.o");
361 | arrayOfFields.add("UD.Shift.r.o");
362 | arrayOfFields.add("H.o");
363 | arrayOfFields.add("DD.o.a");
364 | arrayOfFields.add("UD.o.a");
365 | arrayOfFields.add("H.a");
366 | arrayOfFields.add("DD.a.n");
367 | arrayOfFields.add("UD.a.n");
368 | arrayOfFields.add("H.n");
369 | arrayOfFields.add("DD.n.l");
370 | arrayOfFields.add("UD.n.l");
371 | arrayOfFields.add("H.l");
372 | arrayOfFields.add("DD.l.Return");
373 | arrayOfFields.add("UD.l.Return");
374 | arrayOfFields.add("H.Return");
375 |
376 | ob.put("fields",arrayOfFields);
377 |
378 | JSONArray ar2 = new JSONArray();
379 |
380 | for(int i =0 ; i wml_credentials = new HashMap()
387 | {{
388 | put("url",url);
389 | put("username",username);
390 | put("password",password);
391 | }};
392 |
393 | String wml_auth_header = "Basic " +
394 | Base64.getEncoder().encodeToString((wml_credentials.get("username") + ":" +
395 | wml_credentials.get("password")).getBytes(StandardCharsets.UTF_8));
396 | String wml_url = wml_credentials.get("url") + "/v3/identity/token";
397 | HttpURLConnection tokenConnection = null;
398 | HttpURLConnection scoringConnection = null;
399 | BufferedReader tokenBuffer = null;
400 | BufferedReader scoringBuffer = null;
401 | try {
402 | // Getting WML token
403 | URL tokenUrl = new URL(wml_url);
404 | tokenConnection = (HttpURLConnection) tokenUrl.openConnection();
405 | tokenConnection.setDoInput(true);
406 | tokenConnection.setDoOutput(true);
407 | tokenConnection.setRequestMethod("GET");
408 | tokenConnection.setRequestProperty("Authorization", wml_auth_header);
409 | tokenBuffer = new BufferedReader(new InputStreamReader(tokenConnection.getInputStream()));
410 | StringBuffer jsonString = new StringBuffer();
411 | String line;
412 | while ((line = tokenBuffer.readLine()) != null) {
413 | jsonString.append(line);
414 | }
415 | // Scoring request
416 | URL scoringUrl = new URL(scoringurl);
417 | String wml_token = "Bearer " +
418 | jsonString.toString()
419 | .replace("\"","")
420 | .replace("}", "")
421 | .split(":")[1];
422 | scoringConnection = (HttpURLConnection) scoringUrl.openConnection();
423 | scoringConnection.setDoInput(true);
424 | scoringConnection.setDoOutput(true);
425 | scoringConnection.setRequestMethod("POST");
426 | scoringConnection.setRequestProperty("Accept", "application/json");
427 | scoringConnection.setRequestProperty("Authorization", wml_token);
428 | scoringConnection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
429 | OutputStreamWriter writer = new OutputStreamWriter(scoringConnection.getOutputStream(), "UTF-8");
430 | String payload =ob.toJSONString();
431 | System.out.println("Payload is:" +payload);
432 | writer.write(payload);
433 | writer.close();
434 |
435 | scoringBuffer = new BufferedReader(new InputStreamReader(scoringConnection.getInputStream()));
436 | Object obj = new JSONParser().parse(scoringBuffer);
437 | JSONObject jo = (JSONObject) obj;
438 | JSONArray ja = (JSONArray) jo.get("values");
439 | JSONArray ja_1 = (JSONArray) ja.get(0);
440 | System.out.println("User is : " + ja_1.get(35) + "\n");
441 | System.out.println(ja);
442 |
443 | displayArea.setText("");
444 | JSONArray temp = (JSONArray) ja_1.get(33);
445 | System.out.println(temp);
446 | String strResult = (String)ja_1.get(35);
447 |
448 |
449 | if(strResult.equals("Genuine")){
450 | Double val = (Double) temp.get(1);
451 | val = val * 100.00;
452 | String s = String.format(("%.2f"), val);
453 | displayArea.setFont(new Font("Arial Black", Font.TYPE1_FONT, 15));
454 | displayArea.setText("User is: " +ja_1.get(35) + "\n" + "Confidence Score: " + s +"%");
455 | }else if (strResult.equals("Imposter"))
456 | {
457 | Double val = (Double) temp.get(0);
458 | val = val * 100.00;
459 | String s = String.format(("%.2f"), val);
460 | displayArea.setFont(new Font("Arial Black", Font.PLAIN, 15));
461 | displayArea.setText("User is: " +ja_1.get(35) + "\n" + "Confidence Score: " + s +"%");
462 | }else{
463 | displayArea.setText("Some Network Issues Please try after some time");
464 | }
465 |
466 | } catch (IOException e4) {
467 | System.out.println("The URL is not valid.");
468 | displayArea.setText("Network issue please try after some time else contact nikhil.agrawal005@gmail.com");
469 | System.out.println(e4.getMessage());
470 | }
471 | catch (ParseException e5) {
472 | //some exception handler code.
473 | System.out.println(e5);
474 | }
475 | finally {
476 | if (tokenConnection != null) {
477 | tokenConnection.disconnect();
478 | }
479 | if (tokenBuffer != null) {
480 | try {
481 | tokenBuffer.close();
482 | } catch (IOException e1) {
483 | e1.printStackTrace();
484 | }
485 | }
486 | if (scoringConnection != null) {
487 | scoringConnection.disconnect();
488 | }
489 | if (scoringBuffer != null) {
490 | try {
491 | scoringBuffer.close();
492 | } catch (IOException e1) {
493 | e1.printStackTrace();
494 | }
495 | }
496 | }
497 |
498 | }
499 |
500 |
501 | }
502 |
503 |
--------------------------------------------------------------------------------
/User Authentication Application/src/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: KeyEventDemo
3 |
4 |
--------------------------------------------------------------------------------
/User Authentication Application/src/TypedKeyObject.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by nikhilagrawal on 5/4/18.
3 | */
4 | public class TypedKeyObject {
5 | int id;
6 | Character c;
7 | Long pressTime;
8 | Long releaseTime;
9 | Long releaseTimeinNano;
10 | Long pressTimeinNano;
11 |
12 | public TypedKeyObject(){
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/UserAuthenticationApplication.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nikhilagr/User-Authentication-using-keystroke-dynamics/decc8d1561da870e0001635960cb5d64f06dd1b5/UserAuthenticationApplication.jar
--------------------------------------------------------------------------------