def mssql_old_passwd(password, salt, uppercase=True):
 binsalt = hexdecode(salt)
 unistr = ''.join(map((lambda c: (('%s\x00' if (ord(c) < 256) else '%s') % utf8encode(c))), password))
 retVal = ('0100%s%s%s' % (salt, sha1((unistr + binsalt)).hexdigest(), sha1((unistr.upper() + binsalt)).hexdigest()))
 return ('0x%s' % (retVal.upper() if uppercase else retVal.lower()))

def mssql_old_passwd ( password , salt , uppercase = True ) : binsalt = hexdecode ( salt ) unistr = '' . join ( map ( ( lambda c : ( ( '%s\x00' if ( ord ( c ) < 256 ) else '%s' ) % utf8encode ( c ) ) ) , password ) ) retVal = ( '0100%s%s%s' % ( salt , sha1 ( ( unistr + binsalt ) ) . hexdigest ( ) , sha1 ( ( unistr . upper ( ) + binsalt ) ) . hexdigest ( ) ) ) return ( '0x%s' % ( retVal . upper ( ) if uppercase else retVal . lower ( ) ) )
reference(s): www .