2 Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
33 using std::stringstream;
39 : _value (new uint8_t[ASDCP::KeyLen])
42 rng.FillRandom (_value, ASDCP::KeyLen);
45 Key::Key (uint8_t const * value)
46 : _value (new uint8_t[ASDCP::KeyLen])
48 memcpy (_value, value, ASDCP::KeyLen);
51 Key::Key (string value)
52 : _value (new uint8_t[ASDCP::KeyLen])
55 Kumu::hex2bin (value.c_str(), _value, ASDCP::KeyLen, &length);
58 Key::Key (Key const & other)
59 : _value (new uint8_t[ASDCP::KeyLen])
61 memcpy (_value, other._value, ASDCP::KeyLen);
70 Key::operator= (Key const & other)
76 memcpy (_value, other._value, ASDCP::KeyLen);
85 for (unsigned int i = 0; i < ASDCP::KeyLen; ++i) {
86 g << setw(2) << setfill('0') << std::hex << static_cast<int> (_value[i]);
93 dcp::operator== (Key const & a, Key const & b)
95 return memcmp (a.value(), b.value(), ASDCP::KeyLen) == 0;
99 dcp::operator!= (Key const & a, Key const & b)