6 * Portable ISO 'C' (1994) runtime library for the Amiga computer
7 * Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * - Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * - Neither the name of Olaf Barthel nor the names of contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
34 #define ACrypt __ACrypt
36 #include <exec/types.h>
37 #include <clib/alib_protos.h>
41 /****************************************************************************/
43 #include <aros/debug.h>
45 /****************************************************************************/
49 /****************************************************************************/
51 UBYTE
* ACrypt(UBYTE
* buffer
, const UBYTE
* password
, const UBYTE
* user
);
53 /****************************************************************************/
56 ACrypt(UBYTE
* buffer
, const UBYTE
* password
, const UBYTE
* user
)
58 UBYTE
* result
= NULL
;
65 //assert( buffer != NULL && password != NULL && user != NULL );
67 //SHOWPOINTER(buffer);
68 //SHOWSTRING(password);
70 D(bug("[ACrypt] buffer %p password %s user %s\n", buffer
, password
, user
));
72 if(buffer
== NULL
|| password
== NULL
|| user
== NULL
)
74 //SHOWMSG("invalid parameters");
75 D(bug("[ACrypt] invalid parameters\n"));
79 for(i
= 0 ; i
< OSIZE
; i
++)
81 if((*password
) != '\0')
94 for(i
= 0 ; i
< OSIZE
; i
++)
96 for(k
= 0 ; k
< OSIZE
; k
++)
97 buf
[i
] = (buf
[i
] + buf
[OSIZE
- k
- 1]) % 53;
99 buffer
[i
] = buf
[i
] + 'A';
102 buffer
[OSIZE
-1] = '\0';
104 //SHOWSTRING(buffer);
105 D(bug("[ACrypt] buffer %s\n", buffer
));
112 D(bug("[ACrypt] return value %s\n", result
));