-
Notifications
You must be signed in to change notification settings - Fork 0
/
openssl.m
76 lines (71 loc) · 1.84 KB
/
openssl.m
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
openssl ; openssl wrapper class
dgst(string,type) ; Public ; Generate a message digest
; Usage:
; s digest=$$dgst^openssl(string,type)
; Inputs:
; string = plain text input
; type = message digest type (sha, sha1, sha512, etc)
; Outputs:
; $$dgst = digest of plain text input
;
n i,f,g,x
;
i $g(type)="" s type="sha1"
;
s io=$i
s f="/tmp/openssl.digest.input."_$j_".tmp"
s g="/tmp/openssl.digest.output."_$j_".tmp"
;
o f:NEW
u f w string
c f
;
zsystem "/usr/bin/openssl dgst -"_type_" <"_f_" >"_g
o f
c f:DELETE
;
o g:READ
u g r x
c g:DELETE
;
u io
;
q x
enc(string,cipher,password,mode) ; Public
; Usage:
; s output=$$enc^openssl(string,cipher,password,mode)
; Inputs:
; string = plain text input
; cipher = encryption cipher (bf, des, aes256, etc)
; password = password for encryption
; mode = e - encrypt, d - decrypt
; Outputs:
; $$enc = encrypted or decrypted string
; Notes:
; All encrypted strings are base64 encoded
;
n i,f,g,x
;
i string="" q "" ; Don't try to decrypt nothing
;
i $g(cipher)="" s type="bf"
;
s io=$i
s f="/tmp/openssl.cipher.input."_$j_".tmp"
s g="/tmp/openssl.cipher.output."_$j_".tmp"
;
o f:NEW
u f w string
c f
;
zsystem "/usr/bin/openssl enc -"_cipher_" -"_mode_" -a -A -salt -pass pass:"_password_" -in "_f_" -out "_g
o f
c f:DELETE
;
o g:READ
u g r x
c g:DELETE
;
u io
;
q x