Element ByteGroup::Multiply(const Element &a, const Element &b) const { const QByteArray ba = GetByteArray(a); const QByteArray bb = GetByteArray(b); Q_ASSERT(ba.count() == bb.count()); QByteArray out(ba.count(), 0); const int c = ba.count(); for(int i=0; i<c; i++) { out[i] = ba[i] ^ bb[i]; } return Element(new ByteElementData(out)); }
/** * Returns the string representation */ const QString &ToString() const { if(_string.isEmpty()) { IntegerData *cfree_this = const_cast<IntegerData *>(this); cfree_this->_string = GetByteArray().toBase64(); } return _string; }
/** * Returns the string representation */ const QString &ToString() const { if(_string.isEmpty()) { IntegerData *cfree_this = const_cast<IntegerData *>(this); cfree_this->_string = Utils::ToUrlSafeBase64(GetByteArray()); } return _string; }
bool ByteGroup::IsIdentity(const Element &a) const { if(!IsElement(a)) return false; const QByteArray b = GetByteArray(a); const int c = b.count(); qDebug() << "bytes" << b.toHex(); for(int i=0; i<c; i++) { if(b[i] != 0) return false; } return true; }
Element ByteGroup::Inverse(const Element &a) const { const QByteArray ba = GetByteArray(a); QByteArray out(ba.count(), 0); const int c = ba.count(); for(int i=0; i<c; i++) { out[i] = !ba[i]; } return Element(new ByteElementData(out)); }
bool AsymmetricKey::Save(const QString &filename) const { if(!IsValid()) { return false; } QByteArray data = GetByteArray(); QFile file(filename); if(!file.open(QIODevice::Truncate | QIODevice::WriteOnly)) { qWarning() << "Error (" << file.error() << ") saving file: " << filename; return false; } file.write(data); file.close(); return true; }
KeyedArchive * KeyedArchive::GetArchiveFromByteArray(const String & key) { //DVWARNING(false, "Method is depriceted! Use GetArchive()"); KeyedArchive * archive = new KeyedArchive; int32 size = GetByteArraySize(key); if (size == 0)return 0; const uint8 * array = GetByteArray(key); DynamicMemoryFile * file = DynamicMemoryFile::Create(array, size, File::OPEN | File::READ); if (!archive->Load(file)) { SafeRelease(file); SafeRelease(archive); return 0; } SafeRelease(file); return archive; }
JNIEXPORT jbyteArray JNICALL Java_jACBrFramework_ACBrECF_getRespostaComando(JNIEnv *env, jobject obj) { return GetByteArray(&ECF_GetRespostaComando, env, obj); }
bool ByteGroup::IsElement(const Element &a) const { return (GetByteArray(a).count() == _n_bytes); }
QByteArray ByteGroup::ElementToByteArray(const Element &a) const { return GetByteArray(a); }