tag1
This commit is contained in:
44
src/libs/noteStorage.js
Normal file
44
src/libs/noteStorage.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import {zip, aesEncrypt} from '../libs/secret'
|
||||
import storage from "@/libs/storage";
|
||||
import {getSecretKey} from "@/api/lock";
|
||||
import escapeHtml from "escape-html";
|
||||
|
||||
export function setStoreText(text, secret, password) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
password = "";
|
||||
}
|
||||
|
||||
text = "FLAGNOTE#" + text;
|
||||
|
||||
let secretKey = getSecretKey(secret.cipher, password);
|
||||
let storeText = aesEncrypt(text, secretKey);
|
||||
storeText = zip(storeText);
|
||||
|
||||
console.log("sssssssss" + secret.cipher)
|
||||
console.log("sssssssss" + password)
|
||||
console.log("sssssssss" + secretKey)
|
||||
console.log("s" + storeText)
|
||||
|
||||
let lock = '0';
|
||||
if (password) {
|
||||
lock = '1';
|
||||
}
|
||||
|
||||
storage.local.setText(secret.storeKey + '.text', lock + '|' + secret.cipher + '|' + storeText);
|
||||
}
|
||||
|
||||
|
||||
export function getEscapeText(text) {
|
||||
let textEscape = escapeHtml(text);
|
||||
textEscape = textEscape.replaceAll(" ", " ");
|
||||
textEscape = textEscape.replaceAll("\r\n", "<br/>");
|
||||
textEscape = textEscape.replaceAll("\r", "<br/>");
|
||||
textEscape = textEscape.replaceAll("\n", "<br/>");
|
||||
textEscape = textEscape.replaceAll("\t", " ");
|
||||
|
||||
return textEscape;
|
||||
}
|
||||
Reference in New Issue
Block a user