Add files via upload
This commit is contained in:
@@ -1,49 +1,45 @@
|
||||
import {zip, aesEncrypt} from '../libs/secret'
|
||||
import { wrap } from "@/libs/secret";
|
||||
import storage from "@/libs/storage";
|
||||
import {getSecretKey} from "@/api/lock";
|
||||
import escapeHtml from "escape-html";
|
||||
|
||||
export function setStoreText(noteForm, secret, password) {
|
||||
let text = noteForm.text;
|
||||
export function setStoreText(noteForm, state, secret) {
|
||||
let text = noteForm.text;
|
||||
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
let storeText = "";
|
||||
if (text) {
|
||||
storeText = wrap(text, secret.secretKey);
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
password = "";
|
||||
}
|
||||
|
||||
text = "FLAGNOTE#" + text;
|
||||
|
||||
let secretKey = getSecretKey(noteForm.key, password);
|
||||
let storeText = aesEncrypt(text, secretKey);
|
||||
storeText = zip(storeText);
|
||||
|
||||
let lock = 0;
|
||||
if (password) {
|
||||
lock = 1;
|
||||
}
|
||||
|
||||
|
||||
storage.local.setText(secret.storeKey + '.text', lock + '|' + secret.cipher + '|0|'+ noteForm.initTime+'|' + storeText);
|
||||
storage.local.setText(
|
||||
secret.storeKey,
|
||||
state.lock +
|
||||
"|" +
|
||||
secret.cipher +
|
||||
"|" +
|
||||
state.commited +
|
||||
"|" +
|
||||
state.initTime +
|
||||
"|" +
|
||||
storeText
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export function clearStoreText(key) {
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
storage.local.delete(key);
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
storage.local.delete(key);
|
||||
}
|
||||
|
||||
|
||||
export function getEscapeText(text) {
|
||||
let textEscape = escapeHtml(text);
|
||||
textEscape = textEscape.replace(new RegExp(' ','gm'), " ");
|
||||
textEscape = textEscape.replace(new RegExp('\\r\\n','gm'), "<br/>");
|
||||
textEscape = textEscape.replace(new RegExp('\\r','gm'), "<br/>");
|
||||
textEscape = textEscape.replace(new RegExp('\\n','gm'), "<br/>");
|
||||
textEscape = textEscape.replace(new RegExp('\\t','gm'), "<pre class=\"tab_pre\">	</pre>");
|
||||
return textEscape;
|
||||
let textEscape = escapeHtml(text);
|
||||
textEscape = textEscape.replace(new RegExp(" ", "gm"), " ");
|
||||
textEscape = textEscape.replace(new RegExp("\\r\\n", "gm"), "<br/>");
|
||||
textEscape = textEscape.replace(new RegExp("\\r", "gm"), "<br/>");
|
||||
textEscape = textEscape.replace(new RegExp("\\n", "gm"), "<br/>");
|
||||
textEscape = textEscape.replace(
|
||||
new RegExp("\\t", "gm"),
|
||||
'<pre class="tab_pre">	</pre>'
|
||||
);
|
||||
return textEscape;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user