Skip to content

Commit

Permalink
Set 1 challenge 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Rojas committed Aug 19, 2014
1 parent 75b4885 commit 79366a8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]]
:dependencies [[org.clojure/clojure "1.6.0"], [org.clojure/data.codec "0.1.0"]]
:main ^:skip-aot cryptopals.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
10 changes: 10 additions & 0 deletions src/cryptopals/set1.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(ns cryptopals.set1
(:gen-class))

(require '[clojure.data.codec.base64 :as b64])

(defn convert-hex-to-base64 [s]
(let [hex (new java.math.BigInteger s 16)
binary-hex (.toByteArray hex)]
(String. (b64/encode binary-hex))))

2 changes: 1 addition & 1 deletion test/cryptopals/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

(deftest a-test
(testing "FIXME, I fail."
(is (= 0 1))))
(is (= 1 1))))
7 changes: 7 additions & 0 deletions test/cryptopals/set1_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns cryptopals.set1-test
(:require [clojure.test :refer :all]
[cryptopals.set1 :refer :all]))

(deftest hex-to-base-64
(testing "Convert hex to base64"
(is (= (convert-hex-to-base64 "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d") "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"))))

0 comments on commit 79366a8

Please sign in to comment.