feat: scripts
This commit is contained in:
36
scripts/decrypt.js
Normal file
36
scripts/decrypt.js
Normal file
@@ -0,0 +1,36 @@
|
||||
#! /usr/bin/env runjs
|
||||
|
||||
requireJAR('bcprov-ext-jdk15on-154.jar');
|
||||
requireJAR('crypto-1.0.jar');
|
||||
|
||||
var FileOutputStream = Packages.java.io.FileOutputStream;
|
||||
var DecryptTool = Packages.me.hatter.tools.crypto.stream.DecryptTool;
|
||||
|
||||
|
||||
var main = () => {
|
||||
if ($ARGS.length != 3) {
|
||||
xprintln('[ERROR] parameter error, decrypt.js AES_KEY FILE_NAME_ENC FILE_NAME');
|
||||
return;
|
||||
}
|
||||
var k = __.bytes.fromHex($ARGS[0]).bytes();
|
||||
var encF = $$.rFile($ARGS[1]);
|
||||
var dstF = $$.rFile($ARGS[2]);
|
||||
if (encF.notExists()) {
|
||||
xprintln('[ERROR] Enc file not exists.');
|
||||
return;
|
||||
}
|
||||
if (dstF.exists()) {
|
||||
xprintln('[ERROR] Dest file exists.');
|
||||
return;
|
||||
}
|
||||
var is = encF.inputStream();
|
||||
var dt = new DecryptTool(is, k);
|
||||
var os = dstF.outputStream();
|
||||
xprintln('[INFO] Descrypt ' + encF.file() + ' -> ' + dstF.file() + ' ...');
|
||||
dt.decrypt(os);
|
||||
os.close();
|
||||
is.close();
|
||||
xprintln('[OK] Decrypt file finished.');
|
||||
};
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user