473,320 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Encryption Libraries/classes

Hey gang,
I need to do some encryption/decryption on some strings, so that I
can pass information in the URL in plain sight. Unfortunately, I have
little control over this particular server, so mcrypt is out. Do any of
you know of any good libraries/classes for this?

Thanks,
~D

Jul 17 '05 #1
3 1717
NC
dracolytch wrote:

I need to do some encryption/decryption on some strings,
so that I can pass information in the URL in plain sight.
Why is this preferable to sessions?
Unfortunately, I have little control over this particular
server, so mcrypt is out.


If you don't need anything industrial strength, the simple
Vernam algorithm should help:

function vernam_encrypt($strCryptThis, $strKey) {
$strEncrypted = '';
$n = strlen($strCryptThis);
$k = strlen($strKey);
$j = 0;
for ($i = 0; $i < $n; $i++) {
$iKeyChar = ord($strKey{$j});
$iStringChar = ord($strCryptThis{$i});
$iCryptChar = $iKeyChar ^ $iStringChar;
$strEncrypted = $strEncrypted . chr($iCryptChar);
if ($j >= $k) {
$j = 0;
} else {
$j = $j + 1;
}
}
return $strEncrypted;
}

function vernam_decrypt($strEncrypted, $strKey) {
$strDecrypted = '';
$n = strlen($strEncrypted);
$k = strlen($strKey);
$j = 0;
for ($i = 0; $i < $n; $i++) {
$iKeyChar = ord($strKey{$j});
$iStringChar = ord($strEncrypted{$i});
$iDeCryptChar = $iKeyChar ^ $iStringChar;
$strDecrypted = $strDecrypted . chr($iDeCryptChar);
if ($j >= $k) {
$j = 0;
} else {
$j = $j + 1;
}
}
return $strDecrypted;
}

Cheers,
NC

Jul 17 '05 #2
dracolytch wrote:
Hey gang,
I need to do some encryption/decryption on some strings, so that I
can pass information in the URL in plain sight. Unfortunately, I have
little control over this particular server, so mcrypt is out. Do any of
you know of any good libraries/classes for this?

Thanks,
~D


There's a PHP TEA implementation - try Google.

C.
Jul 17 '05 #3
This is preferable to sessions, because my user-base has a habit of
trying to bookmark search results and sending such links to each other
via email/im. So, I make sure that each page someone looks at has all
the parameters in the URL. I've found that it's generally a good habit
to be in. Your results may vary.

This is, of course, in conflict with the security mantra "Trust no
input your user provides", so I end up doing a lot of (sessions cached)
permission checking.

I can't believe I didn't think of a one-time pad. DOH!

Thanks.
~D

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Joshua Beall | last post by:
Hi All, Up until now I have been storing passwords in the database as an sha1 hash. I like doing it this way, but a problem arises with people who forget their passwords - I cannot retrieve it...
14
by: Ray Cassick \(Home\) | last post by:
Ok, time to ask the question here.. I have been battling over this one for sometime now and just have to ask it. I have created a few classes that I use to act a security keys. These classes get...
8
by: VM | last post by:
Does C# work with encryption and compression? I know that there are C# Encryption class(es) but my client is also interested in compressing the data. We want to use some encryption in the generated...
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
13
by: no game | last post by:
Can I encrypt data more than 117 bytes in C# (can use CAPICOM and Crypto API libraries) using RSA 1024 bit. Any sample code would be appreciated. Thanks
12
by: Mitchell Vincent | last post by:
As the subject suggests, I'm looking for a compression and encryption component(s) for use with VB.NET. I would rather then be all managed code but will use ActiveX/COM if I have to.. Price is...
3
by: The One We Call 'Dave' | last post by:
Hi there, I read a Microsoft paper explaining the basic concepts of encryption. For example, I now understand the difference between asymmetric and symmetric encryption and have successfully...
1
by: Robert Blass | last post by:
I am looking to get my feet wet with encryption. When I say encryption program I am talking about something to get me off to a quick start. Something very simple, far less than the 40+ bit...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.