@@ -10,14 +10,13 @@ use hmac::{Hmac, Mac};
10
10
11
11
/// An implemetation of crypto APIs to optimize fuel.
12
12
/// Currently, hmacSHA256 is the only function implemented.
13
- pub struct Cryptox ;
13
+ pub struct Crypto ;
14
14
15
- impl Intrinsic for Cryptox {
15
+ impl Intrinsic for Crypto {
16
16
unsafe fn add_intrinsic ( ctx : std:: ptr:: NonNull < qjs:: JSContext > ) {
17
- register ( Ctx :: from_raw ( ctx) ) . expect ( "`Cryptox ` APIs to succeed" )
17
+ register ( Ctx :: from_raw ( ctx) ) . expect ( "`Crypto ` APIs to succeed" )
18
18
}
19
19
}
20
-
21
20
fn register ( this : Ctx < ' _ > ) -> Result < ( ) > {
22
21
let globals = this. globals ( ) ;
23
22
@@ -32,7 +31,7 @@ fn register(this: Ctx<'_>) -> Result<()> {
32
31
} ) ,
33
32
) ?;
34
33
35
- globals. set ( "cryptox " , crypto_obj) ?;
34
+ globals. set ( "crypto " , crypto_obj) ?;
36
35
37
36
Ok :: < _ , Error > ( ( ) )
38
37
}
@@ -72,14 +71,14 @@ mod tests {
72
71
#[ test]
73
72
fn test_text_encoder_decoder ( ) -> Result < ( ) > {
74
73
let mut config = Config :: default ( ) ;
75
- config. javy_cryptox ( true ) ;
74
+ config. crypto ( true ) ;
76
75
let runtime = Runtime :: new ( config) ?;
77
76
78
77
runtime. context ( ) . with ( |this| {
79
78
let result: Value < ' _ > = this. eval (
80
79
r#"
81
80
let expectedHex = "97d2a569059bbcd8ead4444ff99071f4c01d005bcefe0d3567e1be628e5fdcd9";
82
- let result = cryptox .hmacSHA256("my secret and secure key", "input message");
81
+ let result = crypto .hmacSHA256("my secret and secure key", "input message");
83
82
expectedHex === result;
84
83
"# ,
85
84
) ?;
@@ -89,4 +88,4 @@ mod tests {
89
88
} ) ?;
90
89
Ok ( ( ) )
91
90
}
92
- }
91
+ }
0 commit comments