File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 63
63
}
64
64
</ style >
65
65
< script >
66
+ const secretCode = '972' ;
67
+
68
+ function generateKeyFromCode ( code ) {
69
+ const baseKey = 'abcdefghijklmnopqrstuvwxyz0123456789' ;
70
+ let shiftedKey = '' ;
71
+ let shift = parseInt ( code ) % 36 ;
72
+ for ( let i = 0 ; i < baseKey . length ; i ++ ) {
73
+ shiftedKey += baseKey [ ( i + shift ) % baseKey . length ] ;
74
+ }
75
+ return shiftedKey ;
76
+ }
77
+
78
+ function encodeUsername ( username , key ) {
79
+ const baseKey = 'abcdefghijklmnopqrstuvwxyz0123456789' ;
80
+ let encoded = '' ;
81
+ for ( let char of username ) {
82
+ let index = baseKey . indexOf ( char ) ;
83
+ if ( index !== - 1 ) {
84
+ encoded += key [ index ] ;
85
+ } else {
86
+ encoded += char ;
87
+ }
88
+ }
89
+ return encoded ;
90
+ }
91
+
66
92
window . onload = function ( ) {
67
93
if ( localStorage . getItem ( 'loggedIn' ) === 'true' ) {
68
94
const username = localStorage . getItem ( 'username' ) ;
83
109
const username = urlParams . get ( 'username' ) ;
84
110
85
111
if ( username ) {
86
- localStorage . setItem ( 'username' , username ) ;
112
+ const key = generateKeyFromCode ( secretCode ) ;
113
+ const encodedUsername = encodeUsername ( username . toLowerCase ( ) , key ) ;
114
+
115
+ localStorage . setItem ( 'username' , encodedUsername ) ;
87
116
localStorage . setItem ( 'loggedIn' , 'true' ) ;
88
117
window . location . href = 'index.html' ;
89
118
}
You can’t perform that action at this time.
0 commit comments