Skip to content

Instantly share code, notes, and snippets.

@dinosaure
Created July 7, 2020 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinosaure/1dddd46b8ef48d223ca91f557a7d7049 to your computer and use it in GitHub Desktop.
Save dinosaure/1dddd46b8ef48d223ca91f557a7d7049 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void shift(unsigned char *a, int size, int shift) {
int carry = 0 ;
while (shift--) {
carry = 0;
for (int i = size - 1; i >= 0; i--) {
int next = (a[i] & 1) ? 0x80 : 0 ;
a[i] = carry | (a[i] >> 1) ;
carry = next;
}
}
}
#define SIZE 40
int main() {
unsigned char a[SIZE] =
{ '\xcb', '\xf0', '\x6a', '\x3f',
'\x29', '\xff', '\xbf', '\xdc',
'\xaf', '\xfc', '\x5b', '\xfe',
'\xff', '\x67', '\x7c', '\xbe',
'\x6a', '\x8e', '\x5a', '\x77',
'\x06', '\x60', '\x45', '\x4a',
'\x64', '\xe2', '\x66', '\x1e',
'\x27', '\x84', '\xa5', '\xca',
'\xc3', '\x00', '\x4a', '\x9c',
'\xae', '\x70', '\x1f', '\xa7' } ;
shift (a, SIZE, 6);
for (int i = 0; i < SIZE; i++)
printf("\\x%02x", a[i]);
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment