I'm trying to implement the RSA algorithm (just for fun, with no padding). My code works fine encrypting up to 83 characters but after this the decryption output is only gibberish and (no matter the size of the input) the output is always 83 bits. Anyone have any idea what's going on here?

Basic encryption procedure:

1.) Take plaintext and concatenate each hex ascii value to form an integer representation of the text. Each hex value will be two digits.

2.) Encrypt this number.

Decryption:

1.) Take ciphertext and decrypt.

2.) Take decrypted number, convert to hex and split up into pairs of digits (i.e. one hex value) and convert to ascii character.

http://pastebin.com/7BtjVQ6n

Any help most appreciated!