def DecryptPassword(cipher, key):
		""" Decrypts the password using the given key with which the password was encrypted first. """
		import base64
		import hmac
		import sha
		from array import array

		H = UcsUtils.GetShaHash

		cipher = cipher + "\n"
		cipher = base64.decodestring(cipher)
		n = len(cipher) - 16 - 8

		uhash = cipher[:16]
		passwordStream = cipher[16:-8] + "0000"[n & 3:]
		auth = cipher[-8:]

		k_enc, k_auth = H('enc' + key + uhash), H('auth' + key + uhash)
		vauth = hmac.new(cipher[-8:], k_auth, sha).digest()[:8]

		passwordStream = array('L', passwordStream)
		xkey = UcsUtils.Expandkey(k_enc, n + 4)

		for i in xrange(len(passwordStream)):
			passwordStream[i] = passwordStream[i] ^ xkey[i]

		decryptedPassword = passwordStream.tostring()[:n]
		return decryptedPassword
def DecryptPassword ( cipher , key ) : import base64 import hmac import sha from array import array H = UcsUtils . GetShaHash cipher = cipher + "\n" cipher = base64 . decodestring ( cipher ) n = len ( cipher ) - 16 - 8 uhash = cipher [ : 16 ] passwordStream = cipher [ 16 : - 8 ] + "0000" [ n & 3 : ] auth = cipher [ - 8 : ] k_enc , k_auth = H ( 'enc' + key + uhash ) , H ( 'auth' + key + uhash ) vauth = hmac . new ( cipher [ - 8 : ] , k_auth , sha ) . digest ( ) [ : 8 ] passwordStream = array ( 'L' , passwordStream ) xkey = UcsUtils . Expandkey ( k_enc , n + 4 ) for i in xrange ( len ( passwordStream ) ) : passwordStream [ i ] = passwordStream [ i ] ^ xkey [ i ] decryptedPassword = passwordStream . tostring ( ) [ : n ] return decryptedPassword
Decrypts the password using the given key with which the password was encrypted first.