This commit is contained in:
Jesse-Ma
2022-05-27 14:29:30 +08:00
parent af75777b4e
commit 0d10a1802a
32 changed files with 1909 additions and 1 deletions

44
src/libs/noteStorage.js Normal file
View 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", "&nbsp;&nbsp;&nbsp;&nbsp;");
return textEscape;
}