示例#1
0
            // Note: It's irritating to have to convert from base64 to bytes and then to hex, but we can't change the IBlobSigner implementation
            // and ServiceAccountCredential.CreateSignature returns base64 anyway.

            public string Sign(RequestTemplate requestTemplate, Options options, IBlobSigner blobSigner, IClock clock)
            {
                var state           = new UrlSigningState(requestTemplate, options, blobSigner, clock);
                var base64Signature = blobSigner.CreateSignature(state._blobToSign);
                var rawSignature    = Convert.FromBase64String(base64Signature);
                var hexSignature    = FormatHex(rawSignature);

                return(state.GetResult(hexSignature));
            }
示例#2
0
            public async Task <string> SignAsync(
                RequestTemplate requestTemplate, Options options, IBlobSigner blobSigner, IClock clock, CancellationToken cancellationToken)
            {
                var state           = new UrlSigningState(requestTemplate, options, blobSigner, clock);
                var base64Signature = await blobSigner.CreateSignatureAsync(state._blobToSign, cancellationToken).ConfigureAwait(false);

                var rawSignature = Convert.FromBase64String(base64Signature);
                var hexSignature = FormatHex(rawSignature);

                return(state.GetResult(hexSignature));
            }