libutil

C Utility Library
git clone http://git.omkov.net/libutil
Log | Tree | Refs | README | LICENCE | Download

libutil/src/crypt.h (32 lines, 907 B) -rw-r--r-- file download

8a5f06f Jamozed 2022-02-09 20:04:50
0
// util/crypt.h, version 0.1.2
98e5939 Jamozed 2021-11-27 17:53:46
1
// Crypt header file from libutil
8e42725 Jamozed 2021-01-26 14:05:12
2
// Copyright (C) 2021, Jakob Wakeling
7f427d9 Jamozed 2022-03-06 12:55:13
3
// MIT Licence
8e42725 Jamozed 2021-01-26 14:05:12
4
98e5939 Jamozed 2021-11-27 17:53:46
5
#ifndef UTIL_CRYPT_H_RDY6J5JV
98e5939 Jamozed 2021-11-27 17:53:46
6
#define UTIL_CRYPT_H_RDY6J5JV
8e42725 Jamozed 2021-01-26 14:05:12
7
8a5f06f Jamozed 2022-02-09 20:04:50
8
#ifdef __cplusplus
8a5f06f Jamozed 2022-02-09 20:04:50
9
extern "C" {
8a5f06f Jamozed 2022-02-09 20:04:50
10
#endif
8a5f06f Jamozed 2022-02-09 20:04:50
11
8e42725 Jamozed 2021-01-26 14:05:12
12
#include <stdint.h>
8e42725 Jamozed 2021-01-26 14:05:12
13
ae5acb7 Jamozed 2021-01-26 17:31:54
14
/* Circular shift left */
8e42725 Jamozed 2021-01-26 14:05:12
15
#define ROL8(x, n)   (uint8_t)(((x) << (n)) | ((x) >>  (8 - (n))))
8e42725 Jamozed 2021-01-26 14:05:12
16
#define ROL16(x, n) (uint16_t)(((x) << (n)) | ((x) >> (16 - (n))))
8e42725 Jamozed 2021-01-26 14:05:12
17
#define ROL32(x, n) (uint32_t)(((x) << (n)) | ((x) >> (32 - (n))))
8e42725 Jamozed 2021-01-26 14:05:12
18
#define ROL64(x, n) (uint64_t)(((x) << (n)) | ((x) >> (64 - (n))))
8e42725 Jamozed 2021-01-26 14:05:12
19
ae5acb7 Jamozed 2021-01-26 17:31:54
20
/* Circular shift right */
8e42725 Jamozed 2021-01-26 14:05:12
21
#define ROR8(x, n)   (uint8_t)(((x) >> (n)) | ((x) <<  (8 - (n))))
8e42725 Jamozed 2021-01-26 14:05:12
22
#define ROR16(x, n) (uint16_t)(((x) >> (n)) | ((x) << (16 - (n))))
8e42725 Jamozed 2021-01-26 14:05:12
23
#define ROR32(x, n) (uint32_t)(((x) >> (n)) | ((x) << (32 - (n))))
8e42725 Jamozed 2021-01-26 14:05:12
24
#define ROR64(x, n) (uint64_t)(((x) >> (n)) | ((x) << (64 - (n))))
8a5f06f Jamozed 2022-02-09 20:04:50
25
8a5f06f Jamozed 2022-02-09 20:04:50
26
#ifdef __cplusplus
8a5f06f Jamozed 2022-02-09 20:04:50
27
} // extern "C"
8a5f06f Jamozed 2022-02-09 20:04:50
28
#endif
8e42725 Jamozed 2021-01-26 14:05:12
29
98e5939 Jamozed 2021-11-27 17:53:46
30
#endif // UTIL_CRYPT_H_RDY6J5JV
31