https://github.com/charonn0/rb-rc4
An RC4 implementation in Realbasic
https://github.com/charonn0/rb-rc4
rc4 realbasic xojo
Last synced: about 1 month ago
JSON representation
An RC4 implementation in Realbasic
- Host: GitHub
- URL: https://github.com/charonn0/rb-rc4
- Owner: charonn0
- License: mit
- Created: 2020-01-17T09:43:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-01T08:09:05.000Z (over 2 years ago)
- Last Synced: 2025-01-26T17:47:52.913Z (3 months ago)
- Topics: rc4, realbasic, xojo
- Language: REALbasic
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RB-RC4
The `RC4Stream` class implements the [RC4 stream cipher](https://en.wikipedia.org/wiki/RC4). RC4 is vulnerable to several forms of attack and generally
should not be used to secure important data. In particular there is no authentication provided. ***Use at your own risk.***The `RC4Stream.RandomBytes()` method returns the specified number of bytes from the RC4 key stream.
The `RC4Stream.Process()` method combines the user-provided bytes with an equal number of bytes from the key stream, performing
both encryption and decryption.The `RC4Stream.Offset` property gets and sets the position in the key stream.
## Example
Encrypt and decrypt a message:
```realbasic
Dim message As String = "Attack at dawn!"
Dim key As String = "seekrit"
Dim rc4 As New RC4Stream(key)
Dim ciphertxt As MemoryBlock = rc4.Process(message) ' encrypt
rc4.Offset = 0 ' reset for decryption
Dim cleartxt As String = rc4.Process(ciphertxt) ' decrypt
```Generate random bytes:
```realbasic
Dim key As String = "seekrit"
Dim rc4 As New RC4Stream(key)
Dim rand As MemoryBlock = rc4.RandomBytes(64) ' generate 64 pseudo-random bytes
```