Skip to content

Instantly share code, notes, and snippets.

@alexandre
Created November 28, 2016 16:07
Show Gist options
  • Save alexandre/e1d2278f60de807c67b886ae134c83c8 to your computer and use it in GitHub Desktop.
Save alexandre/e1d2278f60de807c67b886ae134c83c8 to your computer and use it in GitHub Desktop.
Racket and cryptopals
#lang racket
;; Set 1 - Challenge 1
;; TODO: split string in pairs and convert one by one to int and lookup into ascii table the related character.
(define the-string "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d")
(define (split-in-pairs a-list)
(cond
[(null? a-list) a-list]
[(<= (length a-list) 2) (cons a-list '())]
[else (cons (take a-list 2) (split-in-pairs (cddr a-list)))]))
(define (split-hex-value hex-value)
(split-in-pairs (string->list hex-value)))
(split-hex-value the-string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment