Botan: src/utils/get_byte.h Source File

Botan 1.10.17

get_byte.h
Go to the documentation of this file.
1 /*
2 * Read out bytes
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_GET_BYTE_H__
9 #define BOTAN_GET_BYTE_H__
10
11 #include <botan/types.h>
12
13 namespace Botan {
14
15 /**
16 * Byte extraction
17 * @param byte_num which byte to extract, 0 == highest byte
18 * @param input the value to extract from
19 * @return byte byte_num of input
20 */
21 template<typename T> inline byte get_byte(size_t byte_num, T input)
22 {
23 return static_cast<byte>(
24 input >> ((sizeof(T)-1-(byte_num&(sizeof(T)-1))) << 3)
25 );
26 }
27
28 }
29
30 #endif
Botan::get_byte
byte get_byte(size_t byte_num, T input)
Definition: get_byte.h:21
Botan::byte
unsigned char byte
Definition: types.h:22
Botan
Definition: algo_base.h:14