2009-10-22 143 views
1

嗨需要使用任何腳本生成一個VNC密碼(PHP最好,但任何perl會做)。如何生成VNC密碼?

問題是'vncpasswd'需要交互式用戶操作(提示輸入密碼和密碼驗證)。

有沒有一種方法來生成它沒有提示?

回答

2

here

#!/bin/perl 

use Crypt::CBC; 

my $key = pack("C8", 23, 82, 107, 6, 35, 78, 88, 7); 
$cipher = Crypt::CBC->new({ 
'key'=>$key, 'cipher'=>'DES', 'prepend_iv'=>0, 'regenerate_key'=>0 
}); 

$ciphertext = $cipher->encrypt("This data is hush hush"); 
$plaintext = $cipher->decrypt($ciphertext); 

print "Encrypted: $ciphertext\n"; 
print "Decrypted: $plaintext\n"; 
+0

只需要注意:在加密之前,VNC密碼會被截短(或填充到)長度8。 – ephemient 2009-10-22 15:23:00