forked from p15670423/monkey
Implemented export byte saving to file
This commit is contained in:
parent
308ae3e169
commit
46408e6d32
|
@ -4,18 +4,18 @@ from typing import Dict
|
|||
|
||||
import pyAesCrypt
|
||||
|
||||
# TODO use from pyAesCrypt
|
||||
BUFFER_SIZE = 64 * 1024
|
||||
|
||||
|
||||
def encrypt_config(config: Dict, password: str) -> bytes:
|
||||
def encrypt_config(config: Dict, password: str) -> str:
|
||||
plaintext_config_stream = io.BytesIO(json.dumps(config).encode())
|
||||
ciphertext_config_stream = io.BytesIO()
|
||||
|
||||
pyAesCrypt.encryptStream(
|
||||
plaintext_config_stream, ciphertext_config_stream, password, BUFFER_SIZE
|
||||
)
|
||||
|
||||
ciphertext_config_bytes = ciphertext_config_stream.getvalue()
|
||||
ciphertext_config_bytes = str(ciphertext_config_stream.getvalue())
|
||||
return ciphertext_config_bytes
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {Button, Modal, Form} from 'react-bootstrap';
|
||||
import React, {useState} from 'react';
|
||||
|
||||
import FileSaver from 'file-saver';
|
||||
import AuthComponent from '../AuthComponent';
|
||||
import '../../styles/components/configuration-components/ExportConfigModal.scss';
|
||||
|
||||
|
@ -33,8 +34,12 @@ const ConfigExportModal = (props: Props) => {
|
|||
})
|
||||
}
|
||||
)
|
||||
.then(res => {
|
||||
console.log(res.json());
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
console.log(res);
|
||||
const configAsBinary = new Blob([res['encrypted_config']]);
|
||||
|
||||
FileSaver.saveAs(configAsBinary, 'monkey.conf');
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue