名前 | 形式 | 機能説明 | 属性 | 戻り値 | 使用例 | 関連項目
#include <tsol/tsol.h>int randomword(char *word, char *hyphenated_word, const unsigned short minlen, const unsigned short maxlen, const unsigned char *seed);
randomword ()は、FIPS 181 アルゴリズムを使って発音可能なパスワードを無作為に生成します。成功すると、word は長さ minlenから maxlen までの新しいパスワードに置換されます。hyphenated_word は、word にハイフンが付けられたもので、発音を示します。seed が NULL でない場合は、有効桁 8 文字の乱数 seed です。ユーザーの旧パスワードを選択するとよいでしょう。同じプログラムから randomword() を連続して呼び出すと、seed の NULL ポインタが引き渡され、初期 seed を使って新しい無作為パスワードが生成されます。
次の属性の説明については、attributes(5) のマニュアルページを参照してください。
属性タイプ | 属性値 |
---|---|
使用条件 | SUNWtsu |
MT レベル | MT- 安全 |
randomword() は次の値を返します。
minlen の値が maxlen より大きくなっているか、seed が設定されていない場合。
maxlen の値がゼロ
生成されたパスワード word の長さ。
char password[10]; char hyphen_password[20]; char seed[9]; int len; int i; printf("Please enter old password: "); fgets(seed, 9, stdin); len = randomword(password, hyphen_password, 6, 8, seed); printf("password %s is pronounced %s¥n", password, hyphen_password); for (i = 1; i < 5; i++) { len = randomword(password, hyphen_password, 6, 8, (unsigned char *) 0); printf("password %s is pronounced %s¥n", password, hyphen_password); }