cloud-ide-lms-model 1.0.132 → 1.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -186,19 +186,21 @@ exports.generateRandomAlphanumericString = generateRandomAlphanumericString;
|
|
|
186
186
|
// method to generate string from object this should be encripted and decript json from string
|
|
187
187
|
const generateStringFromObject = (object) => {
|
|
188
188
|
let string = JSON.stringify(object);
|
|
189
|
-
//
|
|
190
|
-
let encryptedString =
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
189
|
+
// Use URL-safe base64 encoding
|
|
190
|
+
let encryptedString = btoa(string);
|
|
191
|
+
// Replace URL-unsafe characters with safe alternatives
|
|
192
|
+
encryptedString = encryptedString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
194
193
|
return encryptedString;
|
|
195
194
|
};
|
|
196
195
|
exports.generateStringFromObject = generateStringFromObject;
|
|
197
196
|
const generateObjectFromString = (string) => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
// Restore base64 padding and replace safe characters back
|
|
198
|
+
let paddedString = string.replace(/-/g, '+').replace(/_/g, '/');
|
|
199
|
+
// Add padding if needed
|
|
200
|
+
while (paddedString.length % 4) {
|
|
201
|
+
paddedString += '=';
|
|
201
202
|
}
|
|
203
|
+
let decryptedString = atob(paddedString);
|
|
202
204
|
let object = JSON.parse(decryptedString);
|
|
203
205
|
return object;
|
|
204
206
|
};
|