mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-03-28 00:05:53 +00:00
added file option to encript
This commit is contained in:
parent
430413c572
commit
4ee9833314
@ -157,7 +157,7 @@ export const encryptDataGroup = ({ data64, publicKeys }) => {
|
|||||||
encryptedKeys.push(encryptedKey);
|
encryptedKeys.push(encryptedKey);
|
||||||
});
|
});
|
||||||
|
|
||||||
const str = "qortalEncryptedData";
|
const str = "qortalGroupEncryptedData";
|
||||||
const strEncoder = new TextEncoder();
|
const strEncoder = new TextEncoder();
|
||||||
const strUint8Array = strEncoder.encode(str);
|
const strUint8Array = strEncoder.encode(str);
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ export function decryptDeprecatedSingle(uint8Array, publicKey) {
|
|||||||
|
|
||||||
export function decryptGroupData(data64EncryptedData) {
|
export function decryptGroupData(data64EncryptedData) {
|
||||||
const allCombined = base64ToUint8Array(data64EncryptedData);
|
const allCombined = base64ToUint8Array(data64EncryptedData);
|
||||||
const str = "qortalEncryptedData";
|
const str = "qortalGroupEncryptedData";
|
||||||
const strEncoder = new TextEncoder();
|
const strEncoder = new TextEncoder();
|
||||||
const strUint8Array = strEncoder.encode(str);
|
const strUint8Array = strEncoder.encode(str);
|
||||||
|
|
||||||
|
@ -566,7 +566,6 @@ class WebBrowser extends LitElement {
|
|||||||
|
|
||||||
const { encryptedData, publicKey } = data
|
const { encryptedData, publicKey } = data
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let data = {};
|
let data = {};
|
||||||
if (!encryptedData) {
|
if (!encryptedData) {
|
||||||
@ -579,7 +578,6 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
const uint8Array = base64ToUint8Array(encryptedData)
|
const uint8Array = base64ToUint8Array(encryptedData)
|
||||||
const startsWithQortalEncryptedData = uint8ArrayStartsWith(uint8Array, "qortalEncryptedData");
|
const startsWithQortalEncryptedData = uint8ArrayStartsWith(uint8Array, "qortalEncryptedData");
|
||||||
|
|
||||||
if (startsWithQortalEncryptedData) {
|
if (startsWithQortalEncryptedData) {
|
||||||
|
|
||||||
if (!publicKey) {
|
if (!publicKey) {
|
||||||
@ -598,7 +596,6 @@ class WebBrowser extends LitElement {
|
|||||||
|
|
||||||
}
|
}
|
||||||
const startsWithQortalGroupEncryptedData = uint8ArrayStartsWith(uint8Array, "qortalGroupEncryptedData");
|
const startsWithQortalGroupEncryptedData = uint8ArrayStartsWith(uint8Array, "qortalGroupEncryptedData");
|
||||||
|
|
||||||
if (startsWithQortalGroupEncryptedData) {
|
if (startsWithQortalGroupEncryptedData) {
|
||||||
|
|
||||||
const decryptedData = decryptGroupData(encryptedData)
|
const decryptedData = decryptGroupData(encryptedData)
|
||||||
@ -893,6 +890,9 @@ class WebBrowser extends LitElement {
|
|||||||
response = JSON.stringify(data);
|
response = JSON.stringify(data);
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if (data.file) {
|
||||||
|
data64 = await fileToBase64(data.file)
|
||||||
|
}
|
||||||
|
|
||||||
if (data.encrypt) {
|
if (data.encrypt) {
|
||||||
try {
|
try {
|
||||||
@ -1067,10 +1067,14 @@ class WebBrowser extends LitElement {
|
|||||||
if (!data.encrypt && service.endsWith("_PRIVATE")) {
|
if (!data.encrypt && service.endsWith("_PRIVATE")) {
|
||||||
throw new Error("Only encrypted data can go into private services")
|
throw new Error("Only encrypted data can go into private services")
|
||||||
}
|
}
|
||||||
|
if (data.file) {
|
||||||
|
data64 = await fileToBase64(data.file)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (data.encrypt) {
|
if (data.encrypt) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const encryptDataResponse = encryptDataGroup({
|
const encryptDataResponse = encryptDataGroup({
|
||||||
data64, publicKeys: data.publicKeys
|
data64, publicKeys: data.publicKeys
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user