Permalink
Browse files

Use (planet gh/sha) and add SHA-256.

  • Loading branch information...
1 parent 0f1e585 commit f97b21dc6f1a7fd3642e9efbb88e0386fbb2e4f5 @greghendershott committed Aug 31, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 keys.rkt
View
@@ -1,7 +1,7 @@
#lang racket
(require net/base64
- web-server/stuffers/hmac-sha1
+ (planet gh/sha)
"util.rkt")
;; These parameters hold the AWS keys. Set them before using functions
@@ -47,10 +47,18 @@
"Tip: `(read-keys)' will read them "
"from a ~~/.aws-keys file."))))
-(define/contract/provide (sha1-encode str)
- (string? . -> . string?)
+(define/contract (shaX-encode str f)
+ (string? (bytes? bytes? . -> . bytes?) . -> . string?)
(match (bytes->string/utf-8
- (base64-encode (HMAC-SHA1 (string->bytes/utf-8 (private-key))
- (string->bytes/utf-8 str))))
+ (base64-encode (f (string->bytes/utf-8 (private-key))
+ (string->bytes/utf-8 str))))
[(regexp #rx"^(.*)\r\n$" (list _ x)) x] ;kill \r\n added by base64-encode
[s s]))
+
+(define/contract/provide (sha1-encode str)
+ (string? . -> . string?)
+ (shaX-encode str hmac-sha1))
+
+(define/contract/provide (sha256-encode str)
+ (string? . -> . string?)
+ (shaX-encode str hmac-sha256))

0 comments on commit f97b21d

Please sign in to comment.