-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdecrypt.ts
More file actions
33 lines (26 loc) · 981 Bytes
/
decrypt.ts
File metadata and controls
33 lines (26 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { decrypt } from './src/rest/decrypt'
// tslint:disable: no-console
console.error('=========================================')
console.error('THIS SCRIPT IS USED FOR DEV PURPOSES ONLY')
console.error("IF YOU'RE SEEING THIS AS AN END USER,")
console.error('SOMETHING WENT WRONG')
console.error('=========================================')
function usage(): never {
console.error('Usage: npx ts-node -T encrypted preimage')
console.error(' Decrypted JSON gets printed to')
console.error(' stdout, so this script can be')
console.error(' piped into jq')
return process.exit(1)
}
const [exec, program, encrypted, preimage, ...rest] = process.argv
if (!encrypted || !preimage) {
usage()
}
console.error('Encrypted:', encrypted)
console.error('Preimage:', preimage)
try {
const decrypted = decrypt(encrypted, preimage)
console.info(decrypted)
} catch (err) {
console.error('Error when decrypting:', (err as Error).message)
}