Beispiel #1
0
def c2():
    EXAMPLE_INPUT = ('1c0111001f010100061a024b53535009181c',
                     '686974207468652062756c6c277320657965')
    EXAMPLE_OUTPUT = '746865206b696420646f6e277420706c6179'
    plainbytes, keybytes = map(crypto.hex_to_bytes, EXAMPLE_INPUT)
    crypt_bytes = crypto.crypt_xor(plainbytes, keybytes)
    result = crypto.bytes_to_hex(crypt_bytes)
    print(result)
    expect(result, EXAMPLE_OUTPUT)
Beispiel #2
0
def c2():
    EXAMPLE_INPUT = ('1c0111001f010100061a024b53535009181c',
                     '686974207468652062756c6c277320657965')
    EXAMPLE_OUTPUT = '746865206b696420646f6e277420706c6179'
    plainbytes, keybytes = map(crypto.hex_to_bytes, EXAMPLE_INPUT)
    crypt_bytes = crypto.crypt_xor(plainbytes, keybytes)
    result = crypto.bytes_to_hex(crypt_bytes)
    print(result)
    expect(result, EXAMPLE_OUTPUT)
Beispiel #3
0
def challenge_2():
	hex_string = "1c0111001f010100061a024b53535009181c"
	xor_string = "686974207468652062756c6c277320657965"
	expected_result = "746865206b696420646f6e277420706c6179"

	plaintext_bytes, xor_bytes = map(crypto.hex_to_bytes, (hex_string, xor_string))
	result_bytes = crypto.flexible_xor(plaintext_bytes, xor_bytes)
	result = crypto.bytes_to_hex(result_bytes)	
	
	test(expected_result, result)
Beispiel #4
0
def challenge_5():
	plaintext = "Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal"
	xor_key = "ICE"

	plaintext_bytes = crypto.string_to_bytes(plaintext)
	xor_bytes = crypto.string_to_bytes(xor_key)

	result_bytes = crypto.flexible_xor(plaintext_bytes, xor_bytes)		
	result = crypto.bytes_to_hex(result_bytes)
	
	print("Result: %s" % result)
Beispiel #5
0
def c5():
    PLAINTEXT = ("Burning 'em, if you ain't quick and nimble\n" +
                 "I go crazy when I hear a cymbal")
    KEY = "ICE"
    EXPECTED = ('0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c' +
                '2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b' +
                '2027630c692b20283165286326302e27282f')
    result = crypto.bytes_to_hex(
        crypto.crypt_xor(crypto.str_to_bytes(PLAINTEXT),
                         crypto.str_to_bytes(KEY)))
    print(result)
    expect(result, EXPECTED)
Beispiel #6
0
def c5():
    PLAINTEXT = ("Burning 'em, if you ain't quick and nimble\n" +
                 "I go crazy when I hear a cymbal")
    KEY = "ICE"
    EXPECTED = ('0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c' +
                '2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b' +
                '2027630c692b20283165286326302e27282f')
    result = crypto.bytes_to_hex(crypto.crypt_xor(
                                          crypto.str_to_bytes(PLAINTEXT),
                                          crypto.str_to_bytes(KEY)))
    print(result)
    expect(result, EXPECTED)
def c5():
    PLAINTEXT = "Burning 'em, if you ain't quick and nimble\n" + \
        "I go crazy when I hear a cymbal"

    KEY = 'ICE'

    EXAMPLE_OUTPUT = '0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272' + \
        'a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f'


    plain, key = map(crypto.str_to_bytes, (PLAINTEXT, KEY))
    cipher = crypto.fixed_xor(plain, key)
    result = crypto.bytes_to_hex(cipher)

    print(result)
    expect(result, EXAMPLE_OUTPUT)