File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
csharp/rocketmq-client-csharp Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -59,15 +59,17 @@ public static Dictionary<string, string> Sign(Client client)
59
59
60
60
var secretData = Encoding . ASCII . GetBytes ( credentials . AccessSecret ) ;
61
61
var data = Encoding . ASCII . GetBytes ( time ) ;
62
- var signer = new HMACSHA1 ( secretData ) ;
63
- var digest = signer . ComputeHash ( data ) ;
64
- var hmac = BitConverter . ToString ( digest ) . Replace ( "-" , "" ) ;
65
- var authorization = $ "{ MetadataConstants . AlgorithmKey } " +
66
- $ "{ MetadataConstants . CredentialKey } ={ credentials . AccessKey } , " +
67
- $ "{ MetadataConstants . SignedHeadersKey } ={ MetadataConstants . DateTimeKey } , " +
68
- $ "{ MetadataConstants . SignatureKey } ={ hmac } ";
69
- dictionary . Add ( MetadataConstants . Authorization , authorization ) ;
70
- return dictionary ;
62
+ using ( var signer = new HMACSHA1 ( secretData ) )
63
+ {
64
+ var digest = signer . ComputeHash ( data ) ;
65
+ var hmac = BitConverter . ToString ( digest ) . Replace ( "-" , "" ) ;
66
+ var authorization = $ "{ MetadataConstants . AlgorithmKey } " +
67
+ $ "{ MetadataConstants . CredentialKey } ={ credentials . AccessKey } , " +
68
+ $ "{ MetadataConstants . SignedHeadersKey } ={ MetadataConstants . DateTimeKey } , " +
69
+ $ "{ MetadataConstants . SignatureKey } ={ hmac } ";
70
+ dictionary . Add ( MetadataConstants . Authorization , authorization ) ;
71
+ return dictionary ;
72
+ }
71
73
}
72
74
}
73
75
}
You can’t perform that action at this time.
0 commit comments