@@ -0,0 +1,1936 @@
+package imgproxytest;%0A%0Aimport com.amazonaws.util.Base16;%0Aimport org.apache.commons.codec.binary.Base64;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport javax.crypto.Mac;%0Aimport javax.crypto.spec.SecretKeySpec;%0A%0Apublic class imgproxy %7B%0A%0A    @Test%0A    public void testWithJavaHmacApacheBase64ImgProxyTest() throws Exception %7B%0A%0A        String Key = %22943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881%22;%0A        String Salt = %22520f986b998545b4785e0defbc4f3c1203f22de2374a3d53cb7a7fe9fea309c5%22;%0A        String Url = %22http://img.example.com/pretty/image.jpg%22;%0A%0A        String Resize = %22fill%22;%0A        int Width = 300;%0A        int Height = 300;%0A        String Gravity = %22no%22;%0A        int Enlarge = 1;%0A        String Extension = %22png%22;%0A        String urlWithHash = GenerateSignedUrlImgProxy(Key, Salt, Url, Resize, Width, Height, Gravity, Enlarge, Extension);%0A%0A        Assert.assertEquals(%22/_PQ4ytCQMMp-1w1m_vP6g8Qb-Q7yF9mwghf6PddqxLw/fill/300/300/no/1/aHR0cDovL2ltZy5leGFtcGxlLmNvbS9wcmV0dHkvaW1hZ2UuanBn.png%22, urlWithHash);%0A    %7D%0A%0A%0A    public static String GenerateSignedUrlImgProxy(String key, String salt, String url, String resize, int width, int height, String gravity, int enlarge, String extension) throws Exception %7B%0A        final String HMACSHA256 = %22HmacSHA256%22;%0A%0A        byte%5B%5D keybin = Base16.decode(key);%0A        byte%5B%5D saltBin = Base16.decode(salt);%0A%0A        String encodedUrl = Base64.encodeBase64URLSafeString(url.getBytes());%0A%0A        String path = %22/%22 + resize + %22/%22 + width + %22/%22 + height + %22/%22 + gravity + %22/%22 + enlarge + %22/%22 + encodedUrl + %22.%22 + extension;%0A%0A        Mac sha256_HMAC = Mac.getInstance(HMACSHA256);%0A        SecretKeySpec secret_key = new SecretKeySpec(keybin, HMACSHA256);%0A        sha256_HMAC.init(secret_key);%0A        sha256_HMAC.update(saltBin);%0A%0A        String hash = Base64.encodeBase64URLSafeString(sha256_HMAC.doFinal(path.getBytes()));%0A%0A        return %22/%22 + hash + path;%0A    %7D%0A%7D%0A

Create signature.java (#64)