Sep 7, 2015 06:41 AM
(This post was last modified: Sep 7, 2015 07:07 AM by The_R.)
Wel,
My last post was about XORing data with the key no bigger than 255 bytes.
Well the bytearray() is simply explained will change a character like "F" to the ASCII table decimal number "70" Than compares it to the key. So the problem was that the key only can be 255 bytes.. This is easily bruteforceable.
So in my next script the key will be a sentence or a word or whatever that will be compared with the plaintext. This is done to convert every character in the key variable to ASCII number.
Example:
the output will be:
every character in "pretty.good.key" will be converted and compared with the plaintext.
Full script:
My last post was about XORing data with the key no bigger than 255 bytes.
Well the bytearray() is simply explained will change a character like "F" to the ASCII table decimal number "70" Than compares it to the key. So the problem was that the key only can be 255 bytes.. This is easily bruteforceable.
So in my next script the key will be a sentence or a word or whatever that will be compared with the plaintext. This is done to convert every character in the key variable to ASCII number.
Example:
PHP Code
<?php
key1 = []
key = "pretty.good.key"
for i in range(len(key)):
key1.append(ord(key[i]
PHP Code
<?php
[112, 114, 101, 116, 116, 121, 46, 103, 111, 111, 100, 46, 107, 101, 121]
every character in "pretty.good.key" will be converted and compared with the plaintext.
Full script:
PHP Code
<?php
import sys
import base64
string = str(raw_input("String to encode with XOR? "))
key1 = []
key = "this.could.be.anything"
for i in range(len(key)):
key1.append(ord(key[i]))
print key1
bytes = bytearray(string)
for c in range(len(bytes)):
bytes[c] ^=key1[i]
print "Encrypted: ", bytes
decode = bytearray(bytes)
for v in range(len(decode)):
decode[v] ^=key1[i]
print "Decoded: ", decode

