Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pandora

Name: Anonymous 2008-01-24 20:22

# pandora.com v15 xmlrpc encrypt/decrypt routines
# for data sent to /radio/xmlrpc/v15 in a POST
# usage:
#   _xmlrpc_request_ = pandora_decrypt(_POST_data_)
#   _POST_data_ = pandora_encrypt(_xmlrpc_request_)

P = [0x62b25781, 0x36c6e49e, 0x79cecc68, 0x16a94f4, 0xb23506e5, 0xf3209930, 0x31cc9e6f, 0xf9c1c6f, 0x3ada9d11, 0xf8b18ccf, 0x8788eb, 0x3433eb64, 0x1bccf5a3, 0xdf91b435, 0xa50ea6fa, 0x8c069dcc, 0x1ff83b56, 0xa75abeba]

S = [[],[],[],[]]

S[0] =
see post >>2

S[1] =
see post >>3

S[2] =
see post >>4

S[3] =
see post >>5

def blowfish_round_function(XL):
    F = S[0][XL>
>24]
    F += S[1][(XL>
>16)&0xff]
    F &= 0xffffffff
    F ^= S[2][(XL>
>8)&0xff]
    F += S[3][XL&0xff]
    F &= 0xffffffff
    return F

def blowfish_block_decrypt(XL, XR):
    for i in xrange(17, 1, -1):
            XL ^= P[i]
            XR ^= blowfish_round_function(XL)
            XL, XR = XR, XL
    XL, XR = XR, XL
    XR ^= P[1]
    XL ^= P[0]
    return [XL, XR]

def blowfish_block_encrypt(XL, XR):
    for i in xrange(16):
            XL ^= P[i]
            XR ^= blowfish_round_function(XL)
            XL, XR = XR, XL
    XL, XR = XR, XL
    XR ^= P[16]
    XL ^= P[17]
    return [XL, XR]

def blowfish_intlist_decrypt(Li):
    Lo = []
    for i in xrange(0, len(Li), 2):
        Lo.extend(blowfish_block_decrypt(Li[i], Li[i+1]))
    return Lo

def blowfish_intlist_encrypt(Li):
    Lo = []
    for i in xrange(0, len(Li), 2):
        Lo.extend(blowfish_block_encrypt(Li[i], Li[i+1]))
    return Lo

def hexstr_to_intlist(H):
    L = []
    Hl = len(H)
    Hm = Hl%8
    for i in xrange(0, Hl-Hm, 8):
        L.append(int(H[i:i+8],16))
    if Hm > 0:
        L.append(int(H[Hl-Hm:]+('0'*(8-Hm)),16))
    return L

def intlist_to_hexstr(L):
    H = ""
    for I in L:
        s = hex(I).replace('0x','').replace('L','')
        H += ('0'*(8-len(s)))+s
    return H

def str_to_intlist(S):
    L = []
    Sl = len(s)
    Sm = Sl%4
    if Sm > 0:
        S += chr(0)*(4-Sm)
    for i in xrange(0, len(S), 4):
        L.append((ord(S[i])<<24)+(ord(S[i+1])<<16)+(ord(S[i+2])<<8)+ord(S[i+3]))
    return L

def intlist_to_str(L):
    S = ""
    for I in L:
        S += chr(I>
>24&0xff)+chr(I>>16&0xff)+chr(I>>8&0xff)+chr(I&0xff)
    return S

def pandora_encrypt(S):
    return intlist_to_hexstr(blowfish_intlist_encrypt(str_to_intlist(S)))

def pandora_decrypt(H):
    return intlist_to_str(blowfish_intlist_decrypt(hexstr_to_intlist(H)))

Name: Anonymous 2008-02-02 17:18

>>40
Doesn't recursion require more overhead than iteration, typically?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List