def rar3_s2k(psw, salt):
 seed = (psw.encode('utf-16le') + salt)
 iv = EMPTY
 h = sha1()
 for i in range(16):
  for j in range(16384):
   cnt = S_LONG.pack(((i * 16384) + j))
   h.update((seed + cnt[:3]))
   if (j == 0):
    iv += h.digest()[19:20]
 key_be = h.digest()[:16]
 key_le = pack('<LLLL', *unpack('>LLLL', key_be))
 return (key_le, iv)

def rar3_s2k ( psw , salt ) : seed = ( psw . encode ( 'utf-16le' ) + salt ) iv = EMPTY h = sha1 ( ) for i in range ( 16 ) : for j in range ( 16384 ) : cnt = S_LONG . pack ( ( ( i * 16384 ) + j ) ) h . update ( ( seed + cnt [ : 3 ] ) ) if ( j == 0 ) : iv += h . digest ( ) [ 19 : 20 ] key_be = h . digest ( ) [ : 16 ] key_le = pack ( '<LLLL' , * unpack ( '>LLLL' , key_be ) ) return ( key_le , iv )
string-to-key hash for rar3 .