コード例 #1
0
ファイル: ByteGroup.cpp プロジェクト: ranzhao1/Dissent-1
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));
}
コード例 #2
0
ファイル: IntegerData.hpp プロジェクト: nya2/Dissent
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: ByteGroup.cpp プロジェクト: ranzhao1/Dissent-1
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;
}
コード例 #5
0
ファイル: ByteGroup.cpp プロジェクト: ranzhao1/Dissent-1
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));
}
コード例 #6
0
ファイル: AsymmetricKey.cpp プロジェクト: ASchurman/Dissent
  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;
  }
コード例 #7
0
ファイル: KeyedArchive.cpp プロジェクト: galek/dava.framework
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);
}
コード例 #9
0
ファイル: ByteGroup.cpp プロジェクト: ranzhao1/Dissent-1
bool ByteGroup::IsElement(const Element &a) const
{
    return (GetByteArray(a).count() == _n_bytes);
}
コード例 #10
0
ファイル: ByteGroup.cpp プロジェクト: ranzhao1/Dissent-1
QByteArray ByteGroup::ElementToByteArray(const Element &a) const
{
    return GetByteArray(a);
}