Raised This Month: $ Target: $400
 0% 

[INC] RC4 library functions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SirLamer
Senior Member
Join Date: Oct 2008
Old 08-27-2009 , 15:26   [INC] RC4 library functions
Reply With Quote #1

RC4 library functions

This library includes functions for encoding data using te RC4 encryption standard.

Adopted from RC4 encoding function found here:
http://forums.alliedmods.net/showthread.php?t=69349

RC4 is an older encryption method that is no longer considered "secure" due to known vunerabilities and biases in the encryption process. However, it is simple and efficient to perform and it is plenty secure for scenarios where you're not storing or transmitting really important or private data, such as credit card numbers.

These functions are ideally suited for including sensitive or secure data in a data stream or URL to a web server.

Note that raw RC4 output is binary data and is not URL safe. I recommend converting to Base64 using this Base64 library file.


EncodeRC4
EncodeRC4(const String:input[], const String:pwd[], String:output[], maxlen)

Encrypts a text string using RC4.
  • input: The source data to be encrypted.
  • pwd: The password/key used to encode and decode the data.
  • output: The encoded result.
  • maxlen: The maximum length of the output buffer.
Return: None.

Note: This function is NOT binary safe. Use EncodeRC4Binary to encode binary data.

EncodeRC4Binary
EncodeRC4Binary(const String:input[], str_len, const String:pwd[], String:output[], maxlen)

Encrypts binary data using RC4.
  • input: The source data to be encrypted.
  • str_len: The length of the source data.
  • pwd: The password/key used to encode and decode the data.
  • output: The encoded result.
  • maxlen: The maximum length of the output buffer.
Return: None.


For an example application, check out the Jukebox for Source plugin, written by myself:
http://forums.alliedmods.net/showthread.php?t=100537
Here, I use RC4 to encrypt a timestamp into the URLs. This is used to impose an expiry on issued URLs, to stop other game servers from leeching on the music service.
Attached Files
File Type: inc rc4.inc (3.2 KB, 320 views)
__________________
Visit TEAM CHEESUS, a TF2 community with our own brand of injected shenanigans, for added flavor.

Plugins: Jukebox for Source

Last edited by SirLamer; 09-03-2009 at 14:58. Reason: Disabled smilies
SirLamer is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 09-11-2015 , 17:06   Re: [INC] RC4 library functions
Reply With Quote #2

Thanks for this.
ImACow is offline
m_bNightstalker
Senior Member
Join Date: Jan 2015
Location: JWD
Old 09-12-2015 , 20:50   Re: [INC] RC4 library functions
Reply With Quote #3

Quote:
Originally Posted by SirLamer View Post
RC4 is an older encryption method that is no longer considered "secure" due to known vunerabilities and biases in the encryption process.
So true
m_bNightstalker is offline
spumer
Senior Member
Join Date: Aug 2011
Old 09-13-2015 , 08:26   Re: [INC] RC4 library functions
Reply With Quote #4

How about decoding functions?
__________________
spumer is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-13-2015 , 09:22   Re: [INC] RC4 library functions
Reply With Quote #5

rc4 is reciprocal: the encode function decodes

Last edited by Miu; 09-13-2015 at 09:30.
Miu is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode