/
crypto.opa
87 lines (63 loc) · 2.38 KB
/
crypto.opa
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
77
78
79
80
81
82
83
84
85
86
87
/*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* {1 About this module}
*
* This module contains a few encoding functions.
*
* {1 Where should I start ?}
*
* The documentation of this module is not complete. In particular, it could be nice
* to get informations about in what condition such encoding are used, by who, for what reason, etc.
*
* {1 What if I need more ?}
*
**/
/**
* {1 Interface}
*/
import-plugin crypto
Crypto = {{
Base64 = {{
encode = %% BslCrypto.base64_encode %% : string -> string
encode_compact = %% BslCrypto.base64_encode_compact %% : string -> string
encode_multiline = %% BslCrypto.base64_encode_multiline %% : string -> string
decode = %% BslCrypto.base64_decode %% : string -> string
decode2 = %% BslCrypto.base64_decode2 %% : string -> string
}}
Hash = {{
/**
* Produces a HMAC_SHA1 for the given key and message. The first argument
* is the key, the second is the message.
*/
hmac_sha1 = %% BslCrypto.hmac_sha1 %% : string, string -> string
/**
* Produces a HMAC_SHA256 for the given key and message. The first argument
* is the key, the second is the message.
*/
hmac_sha256 = %% BslCrypto.hmac_sha256 %% : string, string -> string
md5 = %% BslCrypto.md5 %% : string -> string
sha2 = %%BslCrypto.sha2%% : string -> string
}}
}}
/**
* {1 Deprecated API}
*
* function used to be exported to the global namespace, which is bad
**/
@deprecated({use="Crypto.Base64.encode"}) base64_encode = Crypto.Base64.encode
@deprecated({use="Crypto.Base64.decode"}) base64_decode = Crypto.Base64.decode
@deprecated({use="Crypto.Hash.hmac_sha1"}) hmac_sha1 = Crypto.Hash.hmac_sha1
@deprecated({use="Crypto.Hash.md5"}) md5 = Crypto.Hash.md5
@deprecated({use="Crypto.Hash.md5"}) Hash = Crypto.Hash