Beispiel #1
0
def main():
  try:
    m = choose_mode()
    dhkx.set_modp( m )
    k = enter_kind()
    p = enter_pwd( k )
    a = cvt_pwd_to_n( k, p )
    u = dhkx.make_pub( a )
    g = format_62( u )
    print()
    print( 'Your public key:', g )
    print( 'Its MD5:', md5( g ) )
    print( 'Now send this key to your party.' )
    print()
    print( 'And receive a public key from your party.' )
    f = clean( input( 'Enter it here: ' ) )
    print( 'Its MD5:', md5( f ) )
    b = parse_62( f )
    c = dhkx.make_key( b, a )
    s = format_62( c )
    print()
    print( 'Your common secret password:'******'Its MD5:', md5( s ) )
  except EOFError:
    pass # hide all output when exiting on ^C
Beispiel #2
0
def set_mode():
  def choose_len():
    m = (1536, 2048, 3072, 4096, 6144, 8192)
    t = "  1 - 1536, 2 - 2048, 3 - 3072, 4 - 4096, 5 - 6144, 6 - 8192 [default]"
    while "mode entering":
      print( "Choose modulo length:" )
      print( t )
      k = input( "Enter number: " )
      if len(k)==0: return 8192
      if k in ("1","2","3","4","5", "6"): return m[int(k)-1]
      if k.isdigit() and int(k) in m: return int(k)
  dhkx.set_modp( choose_len() )