-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
104 lines (100 loc) · 1.76 KB
/
utils.js
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
import {createFingerprint} from 'lesspass';
const getColor = color => {
const colors = [
'#000000',
'#074750',
'#009191',
'#FF6CB6',
'#FFB5DA',
'#490092',
'#006CDB',
'#B66DFF',
'#6DB5FE',
'#B5DAFE',
'#920000',
'#924900',
'#DB6D00',
'#24FE23',
];
const index = parseInt(color, 16) % colors.length;
return colors[index];
};
const getIcon = hash => {
const icons = [
'hashtag',
'heart',
'hotel',
'university',
'plug',
'ambulance',
'bus',
'car',
'plane',
'rocket',
'ship',
'subway',
'truck',
'jpy',
'eur',
'btc',
'usd',
'gbp',
'archive',
'area-chart',
'bed',
'beer',
'bell',
'binoculars',
'birthday-cake',
'bomb',
'briefcase',
'bug',
'camera',
'cart-plus',
'certificate',
'coffee',
'cloud',
'coffee',
'comment',
'cube',
'cutlery',
'database',
'diamond',
'exclamation-circle',
'eye',
'flag',
'flask',
'futbol-o',
'gamepad',
'graduation-cap',
];
const index = parseInt(hash, 16) % icons.length;
return icons[index];
};
export const getFingerprintSettings = hash => {
return (
hash &&
createFingerprint(hash).then(sha256 => {
const hash1 = sha256.substring(0, 6);
const hash2 = sha256.substring(6, 12);
const hash3 = sha256.substring(12, 18);
return {
icon1: getIcon(hash1),
icon2: getIcon(hash2),
icon3: getIcon(hash3),
color1: getColor(hash1),
color2: getColor(hash2),
color3: getColor(hash3),
};
})
);
};
export const DEFAULT_PROFILE = {
uppercase: true,
lowercase: true,
numbers: true,
symbols: true,
length: 16,
counter: 1,
version: 2,
};