adding and fetching docs
This commit is contained in:
13
src/stores/functions/encryption.js
Normal file
13
src/stores/functions/encryption.js
Normal file
@@ -0,0 +1,13 @@
|
||||
function norm_to_ascii(string){return unescape(encodeURIComponent(string))};
|
||||
function norm_to_unicode(string){return decodeURIComponent(escape(string))};
|
||||
function crypt_sym(string,k){return String.fromCharCode.apply(undefined,string.split("").map(function(c){return c.charCodeAt(0)^(k||13)}))};
|
||||
|
||||
export function encrypt(string, key) {
|
||||
//Encrypt a string
|
||||
return btoa(crypt_sym(norm_to_ascii(string), key));
|
||||
}
|
||||
|
||||
export function decrypt(string, key) {
|
||||
//Decrypt a string
|
||||
return crypt_sym(norm_to_unicode(atob(string)), key);
|
||||
}
|
Reference in New Issue
Block a user