1 /* crypt - simple encryption algorithm used for passwords
3 ** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
13 static const char key
[PASSWORD_LENGTH
+ 1] = "Dr. Zoidberg Enterprises, BeMail";
16 _EXPORT
char *get_passwd(const BMessage
*msg
,const char *name
)
18 char *encryptedPassword
;
20 if (msg
->FindData(name
,B_RAW_TYPE
,(const void **)&encryptedPassword
,&length
) < B_OK
|| !encryptedPassword
|| length
== 0)
23 char *buffer
= new char[length
];
24 passwd_crypt(encryptedPassword
,buffer
,length
);
30 _EXPORT
bool set_passwd(BMessage
*msg
,const char *name
,const char *password
)
35 ssize_t length
= strlen(password
) + 1;
36 char *buffer
= new char[length
];
37 passwd_crypt((char *)password
,buffer
,length
);
39 msg
->RemoveName(name
);
40 status_t status
= msg
->AddData(name
,B_RAW_TYPE
,buffer
,length
,false);
43 return (status
>= B_OK
);
47 _EXPORT
void passwd_crypt(char *in
,char *out
,int length
)
51 memcpy(out
,in
,length
);
52 if (length
> PASSWORD_LENGTH
)
53 length
= PASSWORD_LENGTH
;
55 for (i
= 0;i
< length
;i
++)