From owner-freebsd-questions Sat Feb 22 15:33:53 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E108837B401 for ; Sat, 22 Feb 2003 15:33:51 -0800 (PST) Received: from zoon.lafn.org (zoon.lafn.org [206.117.18.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D35543FAF for ; Sat, 22 Feb 2003 15:33:51 -0800 (PST) (envelope-from bc979@lafn.org) Received: from lafn.org (host-66-81-177-240.rev.o1.com [66.81.177.240]) by zoon.lafn.org (8.12.3/8.11.3) with ESMTP id h1MNXn6r023871 for ; Sat, 22 Feb 2003 15:33:49 -0800 (PST) (envelope-from bc979@lafn.org) Date: Sat, 22 Feb 2003 15:33:51 -0800 Subject: encryption of data elements Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Doug Hardie To: freebsd-questions@FreeBSD.ORG Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <197F7250-46BE-11D7-9DF5-000393681B06@lafn.org> X-Mailer: Apple Mail (2.551) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I need to encrypt small data elements. These elements run from about 16 to 64 bytes in size. It would be really handy if the encrypted size were the same as the original size. However, if it can't be I do need to be able to predict the encrypted size in advance. Digging around through openssl I came up with the following approach: #include #include RC4_KEY key; char buf[1000]; char out[2000]; int main (int argc, char *argv[]) { int size, i; size = strlen (argv[2]); RC4_set_key (&key, size, argv[2]); RC4 (&key, strlen(argv[1]), argv[1], out); printf ("%s", out); } Where the first arg is the value and the second is the key. It seems to work but I don't know if this is the best algorithm to use or if there is a better approach. Thanks, -- Doug To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message