renamed to ProcessFileObject()
This commit is contained in:
parent
49d275c1bc
commit
1a87c72eb8
1 changed files with 6 additions and 5 deletions
|
|
@ -30,20 +30,18 @@ function LoadSaveFile(input) {
|
|||
// readAsArrayBuffer(file)
|
||||
inputReader.readAsArrayBuffer(inputFileObject);
|
||||
// addEventListener("load", function) - to decode the file when loaded
|
||||
inputReader.addEventListener("load", FileObjectToArrayBuffer);
|
||||
inputReader.addEventListener("load", ProcessFileObject);
|
||||
|
||||
// 2. Decode file
|
||||
|
||||
// Convert ArrayBuffer to string/text TextDecoder().decode(ArrayBuffer)
|
||||
|
||||
// 3. Convert file to JSON string (optional?)
|
||||
// JSON.stringify(JSON.parse(decrypted), undefined, 2)
|
||||
|
||||
// 4. Paste decoded string file to text area
|
||||
}
|
||||
|
||||
// reads the File object as an Array Buffer
|
||||
function FileObjectToArrayBuffer() {
|
||||
// reads the File object as an Array Buffer and does all other operations (decoding, decryption, conversion to string, pasting to text area)
|
||||
function ProcessFileObject() {
|
||||
let inputArrayBuffer = this.result;
|
||||
|
||||
try {
|
||||
|
|
@ -63,6 +61,9 @@ function FileObjectToArrayBuffer() {
|
|||
// AES decryption (ECB) removes pkcs7 padding (ArrayBuffer)
|
||||
inputArrayBuffer = AESDecryption(inputArrayBuffer);
|
||||
|
||||
// Convert ArrayBuffer to string/text TextDecoder().decode(ArrayBuffer)
|
||||
|
||||
|
||||
alert(`Array Buffer: ${inputArrayBuffer}`);
|
||||
} catch (error) {
|
||||
alert(`The file cannot be decoded. Error: ${error}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue