KekSec

crypter code #3

Feb 28th, 2021
710
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "ARC4.h"
  5. #include <iostream>
  6. #include "ARC4.h"
  7.  
  8. using namespace std;
  9.  
  10. void  ARC4::prga(unsigned char* plaintext, unsigned char* cipher, int size) {
  11.     for (int k = 0;k < size;k++) {
  12.         prgaIndexA = (prgaIndexA + 1) % 256;
  13.         prgaIndexB = (prgaIndexB + sbox[prgaIndexA]) % 256;
  14.         swap(sbox, prgaIndexA, prgaIndexB);
  15.         cipher[k] = sbox[(sbox[prgaIndexA] + sbox[prgaIndexB]) % 256] ^ plaintext[k];
  16.     }
  17. }
  18.  
  19. void  ARC4::prga(char* plaintext, char* cipher, int size) {
  20.     prga((unsigned char*)plaintext, (unsigned char*)cipher, size);
  21. }
  22.  
  23. void ARC4::encrypt(char* plaintext, char* ciphertext, int size) {
  24.     prga(plaintext, ciphertext, size);
  25. }
  26. void ARC4::encrypt(unsigned char* plaintext, unsigned char* ciphertext, int size) {
  27.     prga(plaintext, ciphertext, size);
  28. }
  29. ARC4::ARC4() {
  30. }
  31. void ARC4::swap(unsigned char data[], int i, int j) {
  32.     unsigned char temp = data[i];
  33.     data[i] = data[j];
  34.     data[j] = temp;
  35. }
  36. void ARC4::ksa(unsigned char* key) {
  37.     int j = 0;
  38.     for (int i = 0;i < 256;i++) {
  39.         j = (j + sbox[i] + key[i % sizeKey]) % 256;
  40.         swap(sbox, i, j);
  41.     }
  42. }
  43. void ARC4::setKey(unsigned char  k[], int size) {
  44.     prgaIndexA = 0;
  45.     prgaIndexB = 0;
  46.     sizeKey = size;
  47.     for (int i = 0;i < 256;i++) {
  48.         sbox[i] = (unsigned char)i;
  49.     }
  50.     ksa(k);
  51. }
  52.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×